怎么了。从 ListBox 中的 ComboBox 中选择名称后,必须显示所选公司的所有员工。现在我的问题是,总是在 ListBox 中只显示所选公司的 2 名员工。下面这段代码负责显示。作为记录,我是 VBA 的新手。当然,我的问题是为什么只有两名员工?
过程-从 ComboBox 中单击选定的公司:
Dim RecordSt As Recordset
Dim db As Database
Dim query As String
Dim strKombi30 As String
Dim i As Integer
strKombi30 = Me.Kombi30.Value ''combobox
query = "SELECT [Employees].[First name], [Employees].[Name] FROM" & _
"[Employees] WHERE [Employees].[Company] = '" & Me.Kombi30
Set db = CurrentDb()
Set RecordSt = db.OpenRecordset(query)
RecordSt.MoveFirst
For i = 0 To RecordSt.RecordCount
listContacts.AddItem (RecordSt.Fields("First name").Value & " " & RecordSt.Fields("Name").Value)
RecordSt.MoveNext
Next i