Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populate A Combo Box Based Using a Recordset

Status
Not open for further replies.

zp162002

Programmer
Feb 3, 2003
39
US
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
 
Add the following just before you exit:
Forms!frmSeller!cboAuctionNum = Forms!frmSeller!cboAuctionNum.Column(0, 0)

"Hmmm, it worked when I tested it....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top