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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

adding query items to a Combo Box

Status
Not open for further replies.

rhoenig1277

Programmer
Nov 21, 2002
24
US
I'm trying to create a dynamically filled combo box. I have the data being pulled from the query now I just need to populate the combo box. I've included my code below.

Sub Form_Load()
Dim db
Dim rs
Dim qdfParmQry 'the actual query object

Set db = CurrentDb()
Set qdfParmQry = db.QueryDefs("Car_platforms")
qdfParmQry![Please Enter The Customer Code] = Me.OpenArgs
Set rs = qdfParmQry.OpenRecordset()

rs.MoveLast

MsgBox rs.RecordCount
totcount = rs.RecordCount

rs.MoveFirst

For i = 0 To totcount
MsgBox rs!Platform
i = i + 1
rs.MoveNext
Next
End Sub

This works great for selecting the records and popping up the message box. Now I just need to add the line in the For Next to add the item to the combo box. Any suggestions would be greatly appreciated.

Thanks in advance.
Robert
 
I would do that but I'm selecting the items from the query based on some user input.

Set db = CurrentDb()
Set qdfParmQry = db.QueryDefs("Car_platforms")
qdfParmQry![Please Enter The Customer Code] = Me.OpenArgs
Set rs = qdfParmQry.OpenRecordset()

This is where I'm passing the user input so now I need to populate the combo box with the appropriate recordset.

Thanks
Robert
 
Hi

OK so get the user input in a text box on the form, then requery the combo box (in the after update event of the text box), this means the critiera in the query will be the textbox on the form (eg Forms!MyForm!txtBox)

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
I'm not using text boxes. I'm using buttons. The user starts the form. Clicks the button for GM then clicks the button for cars from there I want a drop down list of all the platforms for the gm cars. I've tried the following line and it's kind of working but not completely. I keep getting an object required error.

For i = 0 To totcount
MsgBox rs!Platform
cbo_platforms.Column(i, 0) = rs!Platform
i = i + 1
rs.MoveNext
Next

cbo_platforms is my combo box name.
I've debugged it and rs!Platform does have a value.

Thanks
Robert
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top