Typically the first combobox has the value of the primary key in some table.
We'll call it CustomerID in TblCustomer. Then the second combobox has the
value of the related foreign key in another table. We'll call it CustomerID
in TblOrder. So in the first combobox you choose a customer and in the
second combobox you choose from a list of orders by that customer. The
rowsource of the first combobox is a query based on TblCustomer. CustomerID
is the first column in the query and the Bound Column property of the
combobox is 1. The combobox is named CustomerID. The rowsource of the second
combobox is a query based on TblOrder. OrderID is the first column in the
query, CustomerID is the second column in the query and the Bound Column
property of the combobox is 1. The combobox is named OrderID. The criteria
for CustomerID is Forms!NameOfYourForm!CustomerID.
Put the following code in the AfterUpdate event of the first combobox:
Me!OrderID.Requery
Me!OrderID.SetFocus
Me!OrderID.DropDown
When you select a customer in the first combobox, the second combobox will
dropdown and only display
orders by the customer you selected. Focus will be on the second combobox.
Steve
"Gord" <x1******@telus.netwrote in message
news:FKnvk.11601$nu6.3003@edtnps83...
When clicking an item from a drop down list on a combo box, how does one
make another combo box make a selection from it's own list? No matter
what event I use for my code in the first combo box, seems to always
generate an error when I try and refer to the other combo box.
I'm aware of the necessity of setting the focus on the second box before
referring to it, unless one is using the default value. I'm too tired to
type out everything I've been playing around with (I've been at it for a
while now) and no matter what I always get some sort of error or unwanted
results. I'm hoping this is not something unusual and that someone can
simply show me a generic example of what might work.
Thanks,
Gord