请告诉我这段代码有什么问题。 它显示错误...... “必须将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
答案 0 :(得分:4)
转到列表项的属性,在数据中找到属性“行源类型”并将其设置为“值列表”。 或者您可以通过添加
在代码中执行此操作Me.Liste3.RowSourceType = "Value List"
在行Dim strSQL As String, strItem As String
希望这有帮助! 最大