By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,679 Members | 2,602 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,679 IT Pros & Developers. It's quick & easy.

Combo box requery

P: 6
I have a form with 2 combo boxes in it. The first combo box is named combo0 and has as its row source:

SELECT DISTINCT [tsam grouped]!field1 FROM [tsam grouped] ORDER BY [field1];

The second combo box has as its row source:

SELECT DISTINCT [TSAM GROUPED]!field2AS Expr1 FROM [TSAM GROUPED] WHERE ((([TSAM GROUPED].field1)=Forms!form1!combo0));

So basically, the user selects from the first combo box which field1 value they want to limit their returned recordset to. Then the second combo box populates with all unique field2 values for that field1 selection.

My problem is this: This form works only one time, and then the second combo box does not change based on what is entered in the first combobox. I *think* I have this narrowed down to having to do something to the On Get Focus property of the second combo box, but I'm not sure what that is. I just need for the second combo box to recalculate each time the first combo box is changed.

It is quite unfortunate that this form will need to be run more than one time in the history of the universe. Otherwise I would be done with this part already :-)Can anyone help?

Thanks in advance!
Jan 24 '07 #1
Share this Question
Share on Google+
7 Replies


P: 6
P.S.

Here's what I've tried: Any number of variations of Me!Combo2.requery in On Get Focus Property. (The second combo box is Combo2)

Thanks!
Jan 24 '07 #2

P: 6
Nevermind, I got it. Just had to do a module in the On get Focus:
Me!Combo2.Requery.

Blah.
Jan 24 '07 #3

MMcCarthy
Expert Mod 10K+
P: 14,534
Nevermind, I got it. Just had to do a module in the On get Focus:
Me!Combo2.Requery.

Blah.
You could also use the Me!Combo2.Requery in the After Update event of Combo0.

Glad you got it to work anyway.

Mary
Jan 25 '07 #4

NeoPa
Expert Mod 15k+
P: 31,276
Well done for finding a solution, but don't feel bad about posting.
Mary's answer is an illustration of the correct way of doing it. Your way will have the desired effect but may also cause it to run the code more often than it needs to.
This really should be run only when a selection is made in Combo0.
Jan 25 '07 #5

NeoPa
Expert Mod 15k+
P: 31,276
You may find this helps too (Example Filtering on a Form).
Jan 25 '07 #6

P: 6
Mary/NeoPa,

Your afterupdate solution in the first combo box causes the 2nd combo box to populate much, much faster than the ongotfocus (on the 2nd combo box) way I was trying.

Thanks!
Jan 26 '07 #7

NeoPa
Expert Mod 15k+
P: 31,276
We're glad we were able to help :)
Jan 26 '07 #8

Post your reply

Sign in to post your reply or Sign up for a free account.