Field change relation (1 Viewer)

J

JudyHHuang

Guest
Here is what I want to do:

I have a field called Category (combo box) on a form, and a field called SubCategory (combo box) on the same form. SubCategory is many to one related to the Category. When Category changes, I want to filter out the related SubCategories for the drop down selection. I tried to put an Macro with a Query on the OnChange event of the Category, it never worked out right.

Any hint or tips will be very much appreciated. I am on Win95B and NT (service pack 6), Access 97.

Thank you.
 

Chris RR

Registered User.
Local time
Today, 12:28
Joined
Mar 2, 2000
Messages
354
Base the combo box for the SubCategory on a query. This query would return only SubCategory, but should have column with a "where" condition for the Category, with a criteria of: Like [Forms]![fMyForm]![Category] & "*"

Then, in your form, let's assume that your SubCategory combo box is called cboSubCategory. In the After Update event of the Category field, you need a little VBA code like this:
Me.cboSubCategory = Null 'clears out the SubCategory
Me.cboSubCategory.Requery 'runs the query for the current Category

You can have Category as a dropdown box, too, that should not be a problem.



[This message has been edited by Chris RR (edited 02-13-2001).]
 

Users who are viewing this thread

Top Bottom