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

Populating a combo box from code 1

Status
Not open for further replies.

ChrisProg

Programmer
Apr 4, 2001
41
0
0
GB
Using access 2000, I have a form with 2 combo boxes.
Combo1 contains group information which when selected I wish to use in a query which populates detailed data in combo2.

Combo1 is populated by a query which works ok. I have tried to use the index value from combo1 as a filter for combo2 but am unable to identify the correct way to do this. I have tried using 'applyfilter' to a docmd in vb but always get a type error (the criteria is numeric). I have tried to update the data from vb code using the change event in combo1, but cannot find an 'addnew' method or its equivalent in vba, so cannot add my values to combo2.

I have also tried to use a named query on combo2 to select the data and have included the criteria in the design mode build function (right click on criteria), but connot find a method of refreshing the query after selecting a value in combo1.

There must be a realy simple way of doing this but can anyone help or or suggest how it can be done?

Many thanks in advance.
 
What is the RowSource for the second combobox (combo2)?
sdraper
 
Many thanks for this site which gives clear instructions on how to make it work.
 
Glad to help! Be sure and bookmark that site. It's my favorite Access web site for sure!
sdraper
 
Now I have the population of the second combo working OK.

Just one small problem I have with this second combo box is that if I select any entry in the list by clicking with mouse, only the first irem in the list is displayed! On checking the value of the listindex on the change event it is always zero. Is there a parameter for the combo box that is wrong? There is no code refereing to combo2 except a requery method in combo1.afterupdate event.
 
Sorry so slow. I have been on vacation for a few days. I'm not sure what the deal is with your combo2... You say "only the first item on the list is displayed" DO the others disappear from the list or when you click an item the combo reverts itself back ot the first item?
sdraper
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top