Combo Box Help

  • Thread starter mattc66 via AccessMonster.com
  • Start date
M

mattc66 via AccessMonster.com

Hi All,

I have a combo box on my form. It is unbound to form. I am obtaining cboBox
data from another table in database. However I need to the cboBox to only
list records that match the customerID from the form it on and the customerID
in the cboBox data.

How can I do that?
 
J

John W. Vinson

Hi All,

I have a combo box on my form. It is unbound to form. I am obtaining cboBox
data from another table in database. However I need to the cboBox to only
list records that match the customerID from the form it on and the customerID
in the cboBox data.

How can I do that?

Rather than basing the combo on the other table, base it on a Query of
the other table; and use the customerID control on the form as a
criterion:

=[Forms]![YourFormName]![CustomerID]

You may need to Requery the combo in the AfterUpdate event of the
CustomerID control (if it's updateable - an autonumber won't be).

John W. Vinson [MVP]
 
M

mattc66 via AccessMonster.com

Okay the first part of your suggestion worked. However the requery, I am not
sure I understand were to put that.. I put it on the cboBox after update and
it doesn't seem to help.

What is happening is the cboBox is working on the first record, but if I move
to the next record and the CustomerID changes on the form the cboBox is still
displaying the customerID from the first record. If I close the form and
then re-open the form on a different customer the cboBox pulls the correct
data. However if I move to the next record it again is still pulling the data
from the first record.

Help..

Thanks

[quoted text clipped - 4 lines]
How can I do that?

Rather than basing the combo on the other table, base it on a Query of
the other table; and use the customerID control on the form as a
criterion:

=[Forms]![YourFormName]![CustomerID]

You may need to Requery the combo in the AfterUpdate event of the
CustomerID control (if it's updateable - an autonumber won't be).

John W. Vinson [MVP]
 
R

Ron2006

If the customerID on the main form is NOT in a combox then do the
requery
of the cboBox in the ONCurrent event of the main form.

Ron
 
M

mattc66 via AccessMonster.com

It is a combo box. How would I handle that?
If the customerID on the main form is NOT in a combox then do the
requery
of the cboBox in the ONCurrent event of the main form.

Ron
 
R

Ron2006

Then I believe you will need to re-issue the query in two places.

In the OnCurrent event of the form AND in the afterupdate (or if you
have limit to list as yes then you can use on change) event of the
combo box.

Remember you will be doing the requery for the other combo box the one
that has the condition on it.

Ron
 
M

mattc66 via AccessMonster.com

The Requery seemed to work at first, but know when I close the form and re-
open it I get the nasty Microsoft Access has encountered a problem and needs
to close....

If I remove the me.cboName.Requery it then works without an error.

Any ideas?

Matt
 
R

Ron2006

A requery, in and of itself will NOT cause access to abort.

This implies to me that something is corrupt. Have you tried a
"Compact and Repair" and then try the requery again. A bad query/
requery can itself abort but typically can not abort Access.

Ron
 

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