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

How to Requery a control in a form

P: n/a
I have created a form that has a few combo boxes on it. On the form I
have ComboBoxA which selects data from a region, and ComboBoxB that
selects individual locations within a selected region. I need to
figure out the correct way to Requery ComboBoxA after I have updated
it. I searched the archive for this list and found a simple solution:
put Me.Requery in the AfterUpdate event of ComboBoxA. However, when
I try this I get an error message "... can't find the macro 'Me'.."
What am I doing wrong ?

Thanks for any help on this, Scott
Nov 12 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Do you mean you actually put "Me.Requery" in the Property Sheet for the
AfterUpdate Event of the Combo Box? That's the only thing I can think of
that would likely give you that particular message.

Two problems: the shortcut "Me" which refers to the active Form, not to a
particular control, can only be used in VBA code, and what you put in the
event property is not VBA code. Thus Access sees it doesn't read "Event
Property", and tries to interpret it as a macro, which it does not find.

To requery ComboBoxA, create an event procedure, and in the code put
Me!ComboBoxA.Requery -- but, be aware that requerying a combo box only makes
certain that its Row Source (the information in the dropdown list) is
up-to-date. I can't imagine why that would be necessary in the Combo's own
AfterUpdate event.

I can't quite determine from your statement of the problem if Combo Boxes A
and B are related to each other, or just to the Information on the Form.
Also "requrey ComboBoxA after I have updated it" -- to what does "it" refer
here, and what do you mean by "updated it"?

Please clarify and perhaps someone will be able to offer suggestions.

Larry Linson
Microsoft Access MVP

"Scott" <ko******@yahoo.com> wrote in message
news:12**************************@posting.google.c om...
I have created a form that has a few combo boxes on it. On the form I
have ComboBoxA which selects data from a region, and ComboBoxB that
selects individual locations within a selected region. I need to
figure out the correct way to Requery ComboBoxA after I have updated
it. I searched the archive for this list and found a simple solution:
put Me.Requery in the AfterUpdate event of ComboBoxA. However, when
I try this I get an error message "... can't find the macro 'Me'.."
What am I doing wrong ?

Thanks for any help on this, Scott

Nov 12 '05 #2

P: n/a
Larry,

Thanks for your reply. Well, in the time it took for this question to
get posted, I did figure out that I was assuming I could use
ME!Combo.Requery as a macro. Oops. I have tried Me!ComboBoxA.Requery
for several event procedures related to ComboBoxA and ComboBoxB, yet I
still haven't quite figured out how to make my form work. Perhaps,
Requery isn't what is needed.

Here's what I want to do: I have a Table with numerous fields
describing where field samples were taken. Two fields in the Table are
REGION and LOCATION. There are several region values in the Table and
numerous location values within each region. I would like to Create a
Form which allows the user to Select the region of interest, then
select a location within that region, then click a button and display
a query of the table based on values passed from the Form.

Here's the problem: On the first pass through MyForm, a user Selects a
region from numberous values in ComboBoxA, then in ComboBoxB, the
RowSource has criteria that only displays a subset of the total
locations based on the value for region that was set in ComboBoxA. The
user selects a location, then click's the button and up pops the
query, just fine. Then I close the query and make a second pass
through MyForm, changing the value of ComboBoxA, and then click in
ComboBoxB. But ComboBoxB still has values corresponding to the values
in ComboBoxA that were set in the first pass through MyForm. How do I
get ComboBoxB to update the RowSource based on the updated value of
ComboBoxA after I have changed ComboBoxA once or more ?
TIA, Scott
Nov 12 '05 #3

P: n/a
Still stummped on this one.... any suggestions will be greatly
appreciated.

Here's what I want to do: I have a Table with numerous fields
describing where field samples were taken. Two fields in the Table are
REGION and LOCATION. There are several region values in the Table and
numerous location values within each region. I would like to Create a
Form which allows the user to Select the region of interest, then
select a location within that region, then click a button and display
a query of the table based on values passed from the Form.

Here's the problem: On the first pass through MyForm, a user Selects a
region from numberous values in ComboBoxA, then in ComboBoxB, the
RowSource has criteria that only displays a subset of the total
locations based on the value for region that was set in ComboBoxA. The
user selects a location, then click's the button and up pops the
query, just fine. Then I close the query and make a second pass
through MyForm, changing the value of ComboBoxA, and then click in
ComboBoxB. But ComboBoxB still has values corresponding to the values
in ComboBoxA that were set in the first pass through MyForm. How do I
get ComboBoxB to update the RowSource based on the updated value of
ComboBoxA after I have changed ComboBoxA once or more ?
TIA, Scott
Nov 12 '05 #4

P: n/a
Ray
ko******@yahoo.com (Scott) wrote in message news:<12**************************@posting.google. com>...
Still stummped on this one.... any suggestions will be greatly
appreciated.

Here's what I want to do: I have a Table with numerous fields
describing where field samples were taken. Two fields in the Table are
REGION and LOCATION. There are several region values in the Table and
numerous location values within each region. I would like to Create a
Form which allows the user to Select the region of interest, then
select a location within that region, then click a button and display
a query of the table based on values passed from the Form.

Here's the problem: On the first pass through MyForm, a user Selects a
region from numberous values in ComboBoxA, then in ComboBoxB, the
RowSource has criteria that only displays a subset of the total
locations based on the value for region that was set in ComboBoxA. The
user selects a location, then click's the button and up pops the
query, just fine. Then I close the query and make a second pass
through MyForm, changing the value of ComboBoxA, and then click in
ComboBoxB. But ComboBoxB still has values corresponding to the values
in ComboBoxA that were set in the first pass through MyForm. How do I
get ComboBoxB to update the RowSource based on the updated value of
ComboBoxA after I have changed ComboBoxA once or more ?
TIA, Scott

Hello Scott,

Just set the "AfterUpdate" property of the first combo box to:

cmbSecondComboBox.requery
or
docmd.requery "cmbSecondComboBox"

Either of these should work.

Regards,

Ray
Nov 12 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.