Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Related Combo Boxes on a SubForm

Status
Not open for further replies.

puforee

Technical User
Oct 6, 2006
741
US
I seem to run into this issue every once in a while and I need a solution if you can. I have a Form with a SubForm.

On the Sub form I have two combo boxes. The second combo box is filtered (in the combo box query) based on the results of the first combo box.

The results are inconsistent. The first record (subform) works correctly. The list on the second combo box is correct for the value in the first combo box.

But on the second and ensuing records.....when I select a value for the first combo box, the second combo box does NOT show me the correct list of values.

Can anyone help please?
 
I think you may need to give some more detail, but here is a shot.

It sounds like you're saying this:

You have 2 combo boxes.
I'll call them cboA and cboB.

cboB filter is based on cboA value.

You want cboB to change IF cboA is changed.

If that is so, then you need an event trigger frmo cboA to cause cboB to requery.

Something like:
Code:
Private Sub cboA_OnChange()
  cboB.Requery
End Sub
Might work.

--

"If to err is human, then I must be some kind of human!" -Me
 
kjv1611

I tried a requery but I used DoCmd. Yours is so much simpler. And, it works.

One of these days I will figure out what code to use in what instance with VBA.

Thank you so much :-D :-D
 
Well, I still don't remember, it seems, half of the time. [wink] Usually I figure out the best method ONLY after thinking about and trying all the wrong methods - or I guess "worst" methods.

If you ever are clueless, you can also try just typing the name of an object or variable (control, form, table, etc - assuming it is already Dimmed correctly), and hit your period, and just see what is there. Most everything shows up. A few may not, but in general, that'll show what you can do.

--

"If to err is human, then I must be some kind of human!" -Me
 
Thanks for the advice....I will remember it and use it in the future. Have a good day.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top