Hi All,
I would like to populate a combo box using a recordset. This is the code I have so far:
Private Sub Form_Current()
Dim strList As String
Dim db As Database
Dim rs As Recordset
DoCmd.Maximize
Set db = CurrentDb
Set rs = db.OpenRecordset("tblAuctionNum", dbOpenDynaset)
rs.MoveFirst
Do Until rs.EOF
If rs.Fields(0) = Forms!frmSeller!txtSellerNameID.Value Then
strList = strList & rs.Fields(1) & ";"
End If
rs.MoveNext
Loop
rs.Close
Forms!frmSeller!cboAuctionNum.RowSource = strList
Set rs = Nothing
End Sub
It works except that the first value in the combo box is always empty or null the first time you view the form. Any idea how to make the first value appear in the source list appear if it exists? Thank you in advance.
Patrick
I would like to populate a combo box using a recordset. This is the code I have so far:
Private Sub Form_Current()
Dim strList As String
Dim db As Database
Dim rs As Recordset
DoCmd.Maximize
Set db = CurrentDb
Set rs = db.OpenRecordset("tblAuctionNum", dbOpenDynaset)
rs.MoveFirst
Do Until rs.EOF
If rs.Fields(0) = Forms!frmSeller!txtSellerNameID.Value Then
strList = strList & rs.Fields(1) & ";"
End If
rs.MoveNext
Loop
rs.Close
Forms!frmSeller!cboAuctionNum.RowSource = strList
Set rs = Nothing
End Sub
It works except that the first value in the combo box is always empty or null the first time you view the form. Any idea how to make the first value appear in the source list appear if it exists? Thank you in advance.
Patrick