[英]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.