Access combo box control by another data field

G

Guest

Hi,
I use a combo box in a form with look-up from a table for selecting data.
Easy enough.

But, I want to only see a selection of the data in the table, depending on a
value in another field in the form.
I the combo box table I have ID, data1, and data.
data1 is the one that shall be equal to the other field.

1, 1, text1
2, 1, text2
3, 2, texta
4, 2, textb
5, 2, textc
etc.


I have tried using the standard query that comes with the combo box, and
then adding a WHERE statement testing against the data fiel in the form, but
it does not work.

Any suggestions anyone?
 
G

Guest

Check this link on "How can I filter one Microsoft Access combobox based on
another combobox selection"

http://www.databasedev.co.uk/filter_combo_boxes.html

===================================
Another way, which I rather because there less code involved

Create a reference in the combo RowSource to the field in the form

Select ID, data1, data From TableName Where data1 =
Forms![FormName]![TextBoxName]

On the after update event of the text box, you need to run the code
Me.[Combo name].Requery
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top