Limit a combo box to certain options

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

This is in Access 2002

I have the following tables:

Company
Contact
Orders

I use the Order table to make my form. The combo box for the company field
on the form looks up from the company table. I want the contact field to
look up only the contacts for the company I have chosen.

I have a relationship between the company and contact tables with referntial
integrity.

The orders table is where all of the order info is stored for each item
ordered. I use this table for all of my queries and reports.

Am I doing this right? Well, I know I am not since I can't get the contact
field to look up the way I want it to. Thanks so much for your help!
 
To limit the second combo box, use a query for its Row Source. Set the WHERE
clause in the query (criteria) to point to the value of the first combo box.

Example:
SELECT tblContacts.ContactName FROM tblContacts WHERE tblContacts.CompanyID
= Forms!frmMyForm!cboFirstCombo;

In the AfterUpdate event of the first combo, requery the second combo.

Example:
Me.cboSecondCombo.Requery
 
I am sorry but I think I am doing something wrong.

When I try to choose the contact name a box appears saying "Enter Parameter
Query". and it shows the following "Forms!MyForm!Company"

Do I have the relationships wrong or what?

Thank you so much for your help!
 
I think I must be doing something wrong.

When I try to choose the contact, a box appears saying "Enter Parameter
Value" and then shows "Forms!MyForm!Company"

Do I have the relationships wrong?

Thanks so much for your help!
 
I must be doing something wrong.

When I try to choose the contact name a box appears with "Enter Parameter
Value" for forms!myforms!company

Do I have the relationships wrong?

Thanks so much!
 
Sorry to be so stupid. I actually figured that out before you responded!

Now no errors show up but there is nothing in the drop down when I try to
choose a contact.

Is this because of the lookups being numbers and/or text?
 
The field that the first combo box is bound to (Bound Column) must be
available in the Contacts table. If you were going to link the two tables,
this is the field you would link them on. The data type must be the same in
both. Have you tried more than one company in case that company doesn't have
any contacts listed? Did you include the requery of the second combo box in
the AfterUpdate event of the first combo box? How are you changing the value
in the first combo box, manually or through code?
 
Back
Top