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

Trying to populate a combo box using SQL

Status
Not open for further replies.

vamoose

Programmer
Oct 16, 2005
320
MX
I am using Access 2000 with a connection to a SQL database which contains 600 records. I am trying to populate a combo box with just the Primary Key values from the SQL database. So far all that shows up is the first record, how do I display the other 599 ? I am using this code:

SQLb = "SELECT Coil FROM CoilSpec.dbo.coilspec"
Set CN = New ADODB.Connection: CN.Open "driver={SQL Server};" & _
"server=172.16.6.172;database=coilspec;uid=dtuttle;password=mpmadmin"
Set rs = CN.Execute(SQLb, , adCmdText)
[Forms]![frm_Start]![cmbWCoilNo] = rs.Fields("coil")

Thanks so much.
 
Why not using the RowSource property of the combo ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
RowSource, please explain. I am a beginner programmer and not very familiar with all the available options.

Thank you
 
Row Source, I think I see now. Create a Data source then a query to return the 600 primary key values, correct ? I would like to do this with SQL if at all possible to prevent having to create the data source on all the machines this needs to be installed on. I hope it is possible to accomplish this with SQL.

Thanks.
 
Have you tried a passthru query with hardcoded connection string ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
No I have not, but I like the sounds of this. Do you have an example to look at ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top