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

Binding a combobox 1

Status
Not open for further replies.

durug

Technical User
Mar 22, 2002
335
CA
Hi everybody!

I have 2 comboboxes in my form.
When I select a value in the first one, I want to populate the second one with values from a table where the criteria is the value selected in the first one, something like:
select * from media where media.CID = me!combo1.column(0)

How shell I proceed?

Thanks a lot.
Durug
 
Set the Rowsource for Combo2 to:

SELECT * FROM media WHERE [media].[CID]=[Forms]![Form1]![combo1];

In Combo1's "after update" event use:

Me!Combo2.Requery

The Column property isn't recognised in a query. If you do need to refer to a column (not necessay in this case), let me know and I'll explain what to do. Oh yes, substitute your form name for Form1
 
Thanks, it's working. Now I have another issue.

I have in the second combo box the 2 records that fulfilled the criteria selected from the first combo.
After I select one of them it will show only the bound column in the combo box. How can I display more than one value in the combo box (since the record is better described through a combination of columns)

Ex.
the records in the 2nd combo are
1 John Rick New York
2 Mark Smith Viena

After I select the first one, the combobox will show 1 or John or Rick depending on the bound column. But I will like to display John Rick.

It's hard to describe the problem, but hopefully I made myself clear.

How can I solve this?

Thanks,
Durug
 
In Combo2's properties:

Set the Column Count to 3

Set the Column Widths to 0;1.5;1.5

The 0, hides the 1st column (1,2 etc). Play about with the widths until the column displays all the text that you want.
 
OK. Done this one too. Thanks.
Last question: hopefully:)
When I load the form both comboxes are blank. (I refer here to the combo box row that is shown, not to the list that is shown when you click on the combobox arrow)

I select something in the first combo, then I select some values in the second combo. Then I select another value in the first combo, the second combo will bring in his hidden list the correct values recording to the criteria but the row of the 2nd combobox will still contain the old value.

How can I clear the shown row from the 2nd combobox when I refresh the values from the first combo box?

Thanks a lot and I hope I'm not totally confusing you :)
Durug
 
In Combo1's "after update" event use:

Me!Combo2.Requery
Me!Combo2 = vbNullString
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top