Select distinct based on a form control

G

Guest

Trying to populate a second combo box in a Form based on the user data input
into the first combo box in the same form.

The all combo boxes are bound to text fields. The statement I’m using is:
SELECT DISTINCT [SubCategory] FROM tblSubCat WHERE
[tblSubCat].[Category]=[Forms]![TestHistoryForm].[txtClaCategory_tab];

Is this the correct syntax for the source on second combo box on the form?
It doesn’t populate at all using the = operator. I do get the second combo
box to populate (with incorrect data) if the operator is <>. What could be
the problem? Any help is appreciated.
 
G

Guest

Hello,

You need to separate your SQL statement from your control's value:

"SELECT DISTINCT [SubCategory] FROM tblSubCat WHERE
[tblSubCat].[Category] = " & [Forms]![TestHistoryForm].[txtClaCategory_tab]
& ";"

Be sure to use your code in the first combo box's after update event to set
the second comb box's row source property.

I hope this helps.

Regards,

Paul
 

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