Steve R.
Retired
- Local time
- Today, 12:32
- Joined
- Jul 5, 2006
- Messages
- 5,620
The code below works, but first grumble, grumble. Access "HELP" was not all that informative and lacked a usable example. So it took a bit of experimenting to solve. Basically you need to build the string as shown below to add data to a multicolumn combobox.
Combobox10 is used for a query and the code below "skips" adding a name to the combobox if the person has not completed an inspection.
Code:
strItem = RMS!RepsNameID & ";" & RMS!RepsName
Combobox10 is used for a query and the code below "skips" adding a name to the combobox if the person has not completed an inspection.
Code:
Private Sub BuildRepList()
Dim DBS As dao.Database
Dim RMS As dao.Recordset
Dim lonRecordCount As Long
Dim strItem As String
Set DBS = CurrentDb
Set RMS = DBS.OpenRecordset("RepsList")
RMS.MoveFirst
Me.Combo10.RowSourceType = "Value List"
Me.Combo10.ColumnHeads = False
Do Until RMS.EOF
lonRecordCount = DCount("[Representative]", "SiteInspRptQry", "[Representative] LIKE '*" & RMS!RepsName & "*'")
If lonRecordCount > 0 Then
strItem = RMS!RepsNameID & ";" & RMS!RepsName
Me.Combo10.AddItem Item:=strItem
End If
RMS.MoveNext
Loop
RMS.Close
Set RMS = Nothing
End Sub