Cascading Combo help

T

Tara

I have two combos on a frmEmployees. 1st combo is cboCity, 2nd is cboZip.
Both are based on the same table. I'm trying to get the second combo to be
limited based on what is chosen in the first combo, but it doesn't appear
that the After Update Event is firing at all. That or I'm missing something
obvious.

The 1st combo's RowSource is as follows:

SELECT DISTINCT [tblZip].[strCity] FROM tblZip ORDER BY [tblZip].[strCity];

The 2nd Combo's RowSource is:

SELECT [tblZip].[numZip], [tblZip].[strCity] FROM tblZip WHERE
((([tblZip].[strCity])=[forms]![frmEmployee]![City]));

In the After Update event of the 1st combo I have:

Me.cboZip.Requery

I've also tried using DoCmd.Requery "cboZip"

Interestingly, if I run the query behind cboZip independently of the After
Update Event, it works fine!

What am I missing here???

Thanks!
 
D

Dirk Goldgar

Tara said:
I have two combos on a frmEmployees. 1st combo is cboCity, 2nd is cboZip.
Both are based on the same table. I'm trying to get the second combo to
be
limited based on what is chosen in the first combo, but it doesn't appear
that the After Update Event is firing at all. That or I'm missing
something
obvious.

The 1st combo's RowSource is as follows:

SELECT DISTINCT [tblZip].[strCity] FROM tblZip ORDER BY
[tblZip].[strCity];

The 2nd Combo's RowSource is:

SELECT [tblZip].[numZip], [tblZip].[strCity] FROM tblZip WHERE
((([tblZip].[strCity])=[forms]![frmEmployee]![City]));

In the After Update event of the 1st combo I have:

Me.cboZip.Requery

I've also tried using DoCmd.Requery "cboZip"

Interestingly, if I run the query behind cboZip independently of the After
Update Event, it works fine!

What am I missing here???


I trust that the first combo box is either named "City" or is bound to the
[City] field.

Maybe the AfterUpdate event is not firing. Is the AfterUpdate event
property of the combo box set to "[Event Procedure]"? If you put a
breakpoint in the event procedure, does execution hit that breakpoint when
you choose a value in the combo box?

Does other VBA code in the database execute? This isn't Access 2007 with
VBA code disabled, is it?
 
T

Tara

Dirk Goldgar said:
Tara said:
I have two combos on a frmEmployees. 1st combo is cboCity, 2nd is cboZip.
Both are based on the same table. I'm trying to get the second combo to
be
limited based on what is chosen in the first combo, but it doesn't appear
that the After Update Event is firing at all. That or I'm missing
something
obvious.

The 1st combo's RowSource is as follows:

SELECT DISTINCT [tblZip].[strCity] FROM tblZip ORDER BY
[tblZip].[strCity];

The 2nd Combo's RowSource is:

SELECT [tblZip].[numZip], [tblZip].[strCity] FROM tblZip WHERE
((([tblZip].[strCity])=[forms]![frmEmployee]![City]));

In the After Update event of the 1st combo I have:

Me.cboZip.Requery

I've also tried using DoCmd.Requery "cboZip"

Interestingly, if I run the query behind cboZip independently of the After
Update Event, it works fine!

What am I missing here???


I trust that the first combo box is either named "City" or is bound to the
[City] field.

Maybe the AfterUpdate event is not firing. Is the AfterUpdate event
property of the combo box set to "[Event Procedure]"? If you put a
breakpoint in the event procedure, does execution hit that breakpoint when
you choose a value in the combo box?

Does other VBA code in the database execute? This isn't Access 2007 with
VBA code disabled, is it?

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Thanks for getting back to me Dirk. Yes, the first combo box is named City and the combo property is set to Event Procedure. I hadn't tried setting a breakpoint, so I just did. It appears to be fine. I'm running Access 2000.
 
D

Dirk Goldgar

Tara said:
Thanks for getting back to me Dirk. Yes, the first combo box is named
City and the combo property is set to Event Procedure. I hadn't tried
setting a breakpoint, so I just did. It appears to be fine. I'm running
Access 2000.


So the AfterUpdate is firing, and so cboZip is being requeried -- you
verified that by stepping through the code from your breakpoint, right?

I don't see where the problem is. I know this may seem like dumb question,
but what exactly are you observing that leads you to believe that the combo
box isn't being requeried?
 
T

Tara

Dirk Goldgar said:
So the AfterUpdate is firing, and so cboZip is being requeried -- you
verified that by stepping through the code from your breakpoint, right?

I don't see where the problem is. I know this may seem like dumb question,
but what exactly are you observing that leads you to believe that the combo
box isn't being requeried?
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

As far as what I'm observing, nothing. Literally. By that I mean that the
2nd combo isn't changing values.

Also, maybe I need to have you explain what I should see after I set the
breakpoint. I'm pretty new to coding so maybe I interpreted it incorrectly.
What happened was once I ran the code, the code window popped up with the
code highlighted yellow. But it never gave me any errors, so I assumed it
was fine.
 
D

Dirk Goldgar

Tara said:
Also, maybe I need to have you explain what I should see after I set the
breakpoint. I'm pretty new to coding so maybe I interpreted it
incorrectly.
What happened was once I ran the code, the code window popped up with the
code highlighted yellow. But it never gave me any errors, so I assumed it
was fine.


That sounds fine. And then you pressed F5 to finish running the code, or
oterwise stepped on out of the procedure?
As far as what I'm observing, nothing. Literally. By that I mean that
the
2nd combo isn't changing values.

Now, there may be a misunderstanding here -- or not. The current value of
combo2 should not change. What should change is the list of selectable
values shown in the combo box's dropdown list. So choosing a new City and
requerying cboZip should cause cboZip to display in its dropdown list only
those zip codes that are associated with that city. However, the current
zip code, displayed when cboZip is not dropped down, should not change
(though it may or may not vanish, depending on the combo box's Limit To List
property).
 
T

Tara

Dirk, sorry about not getting back with you sooner on this. I've been out of
the office.

Anyway, yes, in response to you question, I finished running the code.

It seems like everything is running fine, but there must be something that's
not right. Events don't just not fire for no reason, right?
 

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