How Do I load a ComboBox at Runtime ?

liamfitz

Registered User.
Local time
Today, 08:50
Joined
May 17, 2012
Messages
240
I have set the 'Row Source Type' property of a ComboBox to Table/Query. I have set the 'Row Source' property to qryFullName ( "SELECT tblAdvocates.Forename+' '+tblAdvocates.Surname AS FullName
FROM tblAdvocates;") but it loads nothing in the ComboBox ???? I will check the SQL syntax, but whether it's through creating a recordset in a VBA procedure, and looping through to 'AddItems' to the list, storing the first and surname in a string, or setting a subset to set the RowSource using a query. I wish to concatenate these 2 fields, to create a list for said ComboBox. Please help, it used to be so much easier in earlier versions of VBA !!!
:confused:
 
I tried using what you have mentioned at it works just fine. I mean it loads the values properly. Not sure why it does not work for you.. Check your column count, bound column values for anything more..
 
Check the column widths. If you started off with more than one column it could be that it is set to something like 0";1" and now that you have only one column it would be hiding it.
 
Does the dropdown list show values? Or, is it blank as well as the control?

If the list shows values but the control is empty, either no value was saved or the saved value does not exist in the combo's RowSource.

For example, the field contains "Stratford" if you look at the record in the table but the state was changed to NY and the city list is now filtered to NY cities so the city field appears blank. It isn't. Changing the state back to CT will change the combo's RowSource so it selects CT cities and now Stratford shows.
 
I've done it. Thanks for the pointers and interest. Always grateful ( I set the 'Type' to Value list then loaded it at Run-Time with a a concatenated string derived from the two fields in a recordset, read on an iterative loop. Much more flexible. )
 
What was wrong with binding it to a query/table?
 

Users who are viewing this thread

Back
Top Bottom