简体   繁体   English

这个VBA代码有什么问题

[英]What is wrong with this VBA Code

Please tell me what is wrong with this code. 请告诉我这段代码有什么问题。 It shows error... "The rowsourcetype property must be set to value list to use this" 它显示错误...“rowsourcetype属性必须设置为值列表才能使用此”

Private Sub Form_Load()
     Dim db As DAO.Database
     Dim rs As DAO.Recordset
     Dim strSQL As String, strItem As String

    strSQL = "SELECT CustomerID, CompanyName FROM Customers"
    Set db = CurrentDb
    Set rs = db.OpenRecordset(strSQL)
    Do Until rs.EOF
         strItem = rs.Fields("CustomerID").Value & ";" _
         & rs.Fields("CompanyName").Value
    Me.List1.AddItem strItem      ' Row Source Type must be Value List
    rs.MoveNext

    Loop
    rs.Close
    Set rs = Nothing
    Set db = Nothing
    End Sub

Go to the properties of the list-item, in data you find the property "Row Source Type" and set this to "Value list". 转到列表项的属性,在数据中找到属性“行源类型”并将其设置为“值列表”。 Or you can do ths in the code by putting 或者你可以通过推杆在代码中做

Me.Liste3.RowSourceType = "Value List"

right at the start of your code after the line Dim strSQL As String, strItem As String Dim strSQL As String, strItem As String之后的代码Dim strSQL As String, strItem As String

Hope this helps! 希望这可以帮助! Max 马克斯

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 这个php代码有什么问题,如下所示? - what is wrong with this php code shown as below? 我的代码出现数据库有什么问题? - what's wrong with my code to appear database? vba代码是什么,可以把员工每天的伙食登记在“清单”里? - What is the vba code to register employees' daily meals in a "list"? VBA 代码中 WHERE 关键字的正确语法语法是什么 - What is the correct syntax Syntax for WHERE keyword in VBA Code 我的代码有什么问题? 不会从数据库中删除数据 - What is wrong with my code? Data is not deleted from database 存储过程(菜鸟程序员),我的代码有什么问题? - Stored Procedure (rookie programmer), What's wrong with my code? 这有什么不对? 在我的代码中(将图像插入数据库 - C#) - What is wrong here? In my code (Inserting Image into Database - C#) 创建表时我的python + sqlite3代码有什么问题? - What's wrong with my python + sqlite3 code in creating tables? 通过电子邮件获取用户并检查密码的代码有什么问题? - What;s wrong with code which is getting user by email and checking for the password? 使用UPDATE(mysql)将数据库递增1。 我的代码有什么问题? - Increment database by 1, using UPDATE (mysql). What's wrong with my code?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM