multiple macros on one event

  • Thread starter Thread starter jrlh
  • Start date Start date
J

jrlh

Is it possible to have multiple macros run for one event
(e.g., to run a few different macros on the "On Open"
event)? If so, how?

Thanks,

Jennifer
 
Jennifer,

If you want to stick to macro's (not code), you can create a new macro that
has the command RunMacro. This macro will run all macros that are specified
inside it. This is great if the macros you are running are the same ones
every time.

If the macros are different each time, you'd be better off using code to run
which ever macros you want. Probably a few DoCmd.RunMacro commands.

In both of these, you can specify number of times to repeat macros, and a
conditional statement so that the macros only run when the criteria is met.

Hope this helps,

Piers

| Is it possible to have multiple macros run for one event
| (e.g., to run a few different macros on the "On Open"
| event)? If so, how?
|
| Thanks,
|
| Jennifer
 
Thanks for the advice! Under the RunMacro command, how
do you enter multiple macros under Macro Name? From the
drop-down menu, it seems like you are only able to add
one at a time. My form is pretty simple - my macros are
always the same and only need to be run once. I would
really appreciate your input!

Thanks,
Jennifer
 
Try creating another macro that invokes the multiple macros you want, one at
a time, and set that new macro as the Event handler.
 
I am still having a problem making it work. I am able to
get through two of the macros, but the third one does not
work correctly.

This is what I have so far:

Macro Name: mcrOnOpen
Condition: {blank}
Action: {blank}

This macro maximizes the form window:

Macro Name: {blank}
Condition: {blank}
Action: Maximize (This part works fine.)

This macro opens up a text box to enter in a country name
if outside the United States. "00" indicates a country
oustide the U.S.:

Macro Name: {blank}
Condition: [State]<>"00"
Action: SetValue
Item: [Forms]![frmIDandContactInfo]![SpecifyCountry].
[ColumnHidden]
Expression: True

Macro Name: {blank}
Condition: [State]="00"
Action: SetValue
Item: [Forms]![frmIDandContactInfo]![SpecifyCountry].
[Visible]
Expression: True

Macro Name: {blank}
Condition: ...
Action: StopMacro

Macro Name: {blank}
Condition: {blank}
Action: SetValue
Item: [Forms]![frmIDandContactInfo]![SpecifyCountry].
[Visible]
Expression: False

Macro Name: {blank}
Condition: [SpecifyCountry] Is Not Null
Action: SetValue
Item: [Forms]![frmIDandContactInfo]![SpecifyCountry]
Expression: Null {This macro also works fine.)

The following macro opens up a text box to enter in the
source of a phone number if a number is entered in
under "Other Phone". THIS MACRO ONLY WORKS IF THE TEXT
BOX FOR [STATE]<>"00". IT DOES NOT WORK IN INSTANCES
WHERE [STATE]="00".:

Macro Name: {blank}
Condition: [OtherPhone] Is Null
Action: SetValue
Item: [Forms]![frmIDandContactInfo]![SpecifyOtherPhone].
[ColumnHidden]
Expression: True

Macro Name: {blank}
Condition: [OtherPhone] Is Not Null
Action: SetValue
Item: [Forms]![frmIDandContactInfo]![SpecifyOtherPhone].
[Visible]
Expression: True

Macro Name: {blank}
Condition: ...
Action: StopMacro

Macro Name: {blank}
Condition: {blank}
Action: SetValue
Item: [Forms]![frmIDandContactInfo]![SpecifyOtherPhone].
[Visible]
Expression: False

Macro Name: {blank}
Condition: [SpecifyOtherPhone] Is Not Null
Action: SetValue
Item: [Forms]![frmIDandContactInfo]![SpecifyOtherPhone]
Expression: Null

Macro Name: {blank}
Condition: {blank}
Action: StopMacro

END OF MACROS

If "00" is entered under [State], then no text box will
open to specify the source of a number entered into
[OtherPhone]; however, if anything other than "00" is
entered under [State], then the third macro works just
fine. I'm sure that there is something wrong with one of
my conditions, but I'm new at this and can't figure it
out. Each macro works separately on its own. (Note:
When the second macro stand alone, it ends with a
StopMacro action. If I enter this action in the group of
macros, the third macro shuts down altogether.

I would really appreciate any further input you might be
able to provide!

Thanks!

Jennifer
 
Why not try your hand using VBA instead of macros? VBA is much more
versatile, and allows for proper error handling, something macros lack.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



jrlh said:
I am still having a problem making it work. I am able to
get through two of the macros, but the third one does not
work correctly.

This is what I have so far:

Macro Name: mcrOnOpen
Condition: {blank}
Action: {blank}

This macro maximizes the form window:

Macro Name: {blank}
Condition: {blank}
Action: Maximize (This part works fine.)

This macro opens up a text box to enter in a country name
if outside the United States. "00" indicates a country
oustide the U.S.:

Macro Name: {blank}
Condition: [State]<>"00"
Action: SetValue
Item: [Forms]![frmIDandContactInfo]![SpecifyCountry].
[ColumnHidden]
Expression: True

Macro Name: {blank}
Condition: [State]="00"
Action: SetValue
Item: [Forms]![frmIDandContactInfo]![SpecifyCountry].
[Visible]
Expression: True

Macro Name: {blank}
Condition: ...
Action: StopMacro

Macro Name: {blank}
Condition: {blank}
Action: SetValue
Item: [Forms]![frmIDandContactInfo]![SpecifyCountry].
[Visible]
Expression: False

Macro Name: {blank}
Condition: [SpecifyCountry] Is Not Null
Action: SetValue
Item: [Forms]![frmIDandContactInfo]![SpecifyCountry]
Expression: Null {This macro also works fine.)

The following macro opens up a text box to enter in the
source of a phone number if a number is entered in
under "Other Phone". THIS MACRO ONLY WORKS IF THE TEXT
BOX FOR [STATE]<>"00". IT DOES NOT WORK IN INSTANCES
WHERE [STATE]="00".:

Macro Name: {blank}
Condition: [OtherPhone] Is Null
Action: SetValue
Item: [Forms]![frmIDandContactInfo]![SpecifyOtherPhone].
[ColumnHidden]
Expression: True

Macro Name: {blank}
Condition: [OtherPhone] Is Not Null
Action: SetValue
Item: [Forms]![frmIDandContactInfo]![SpecifyOtherPhone].
[Visible]
Expression: True

Macro Name: {blank}
Condition: ...
Action: StopMacro

Macro Name: {blank}
Condition: {blank}
Action: SetValue
Item: [Forms]![frmIDandContactInfo]![SpecifyOtherPhone].
[Visible]
Expression: False

Macro Name: {blank}
Condition: [SpecifyOtherPhone] Is Not Null
Action: SetValue
Item: [Forms]![frmIDandContactInfo]![SpecifyOtherPhone]
Expression: Null

Macro Name: {blank}
Condition: {blank}
Action: StopMacro

END OF MACROS

If "00" is entered under [State], then no text box will
open to specify the source of a number entered into
[OtherPhone]; however, if anything other than "00" is
entered under [State], then the third macro works just
fine. I'm sure that there is something wrong with one of
my conditions, but I'm new at this and can't figure it
out. Each macro works separately on its own. (Note:
When the second macro stand alone, it ends with a
StopMacro action. If I enter this action in the group of
macros, the third macro shuts down altogether.

I would really appreciate any further input you might be
able to provide!

Thanks!

Jennifer








-----Original Message-----
Try creating another macro that invokes the multiple macros you want, one at
a time, and set that new macro as the Event handler.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)






.
 
Jennifer,

You description refers to 3 macros, but it is not clear what the
relationship is between them. Are they all supposed to be part of a
macro group, or are they in fact in each of 3 separate macros. How are
they being run... are each of them run individually, or is there a
RunMacro action in a 4th macro, as has been suggested elsewhere in this
thread, that is supposed to cycle through all three of these existing
ones? Why haven't you just put all of these actions into one macro... I
can't see any reason why they need to be split into 3 macros at all?

--
Steve Schapel, Microsoft Access MVP
I am still having a problem making it work. I am able to
get through two of the macros, but the third one does not
work correctly.

This is what I have so far:

Macro Name: mcrOnOpen
Condition: {blank}
Action: {blank}

This macro maximizes the form window:

Macro Name: {blank}
Condition: {blank}
Action: Maximize (This part works fine.)

This macro opens up a text box to enter in a country name
if outside the United States. "00" indicates a country
oustide the U.S.:

Macro Name: {blank}
Condition: [State]<>"00"
Action: SetValue
Item: [Forms]![frmIDandContactInfo]![SpecifyCountry].
[ColumnHidden]
Expression: True

Macro Name: {blank}
Condition: [State]="00"
Action: SetValue
Item: [Forms]![frmIDandContactInfo]![SpecifyCountry].
[Visible]
Expression: True

Macro Name: {blank}
Condition: ...
Action: StopMacro

Macro Name: {blank}
Condition: {blank}
Action: SetValue
Item: [Forms]![frmIDandContactInfo]![SpecifyCountry].
[Visible]
Expression: False

Macro Name: {blank}
Condition: [SpecifyCountry] Is Not Null
Action: SetValue
Item: [Forms]![frmIDandContactInfo]![SpecifyCountry]
Expression: Null {This macro also works fine.)

The following macro opens up a text box to enter in the
source of a phone number if a number is entered in
under "Other Phone". THIS MACRO ONLY WORKS IF THE TEXT
BOX FOR [STATE]<>"00". IT DOES NOT WORK IN INSTANCES
WHERE [STATE]="00".:

Macro Name: {blank}
Condition: [OtherPhone] Is Null
Action: SetValue
Item: [Forms]![frmIDandContactInfo]![SpecifyOtherPhone].
[ColumnHidden]
Expression: True

Macro Name: {blank}
Condition: [OtherPhone] Is Not Null
Action: SetValue
Item: [Forms]![frmIDandContactInfo]![SpecifyOtherPhone].
[Visible]
Expression: True

Macro Name: {blank}
Condition: ...
Action: StopMacro

Macro Name: {blank}
Condition: {blank}
Action: SetValue
Item: [Forms]![frmIDandContactInfo]![SpecifyOtherPhone].
[Visible]
Expression: False

Macro Name: {blank}
Condition: [SpecifyOtherPhone] Is Not Null
Action: SetValue
Item: [Forms]![frmIDandContactInfo]![SpecifyOtherPhone]
Expression: Null

Macro Name: {blank}
Condition: {blank}
Action: StopMacro

END OF MACROS

If "00" is entered under [State], then no text box will
open to specify the source of a number entered into
[OtherPhone]; however, if anything other than "00" is
entered under [State], then the third macro works just
fine. I'm sure that there is something wrong with one of
my conditions, but I'm new at this and can't figure it
out. Each macro works separately on its own. (Note:
When the second macro stand alone, it ends with a
StopMacro action. If I enter this action in the group of
macros, the third macro shuts down altogether.

I would really appreciate any further input you might be
able to provide!

Thanks!

Jennifer
 
I have tried putting all three sections into one macro,
but the third one breaks (i.e., it only functions if
anything other than "00" is entered in the [State] field.
The relationship between the macros is that they all
involve modifications to the form as it opens. Except for
the Maximize action, hey all hide text boxes unless a
specific option (e.g., "00" in the [State] field denoting
a country outside the U.S.) opens a text box allowing for
more specific information to be entered, such as the name
of a country. I have also tried having the macros as part
of a group, and have set the AfterUpdate events for the
controls to the group.macroname macro, but this has not
worked either. I am not sure how to use the RunMacro
event if I have more than one macro to add under Macro
Name. If I could figure out what I'm doing wrong with my
conditions (i.e., the reason why the third section only
works with [State]<>"00" and not with [State]="00". If I
can supply anymore information to assist in your reply,
please let me know.

Thanks,
Jennifer
-----Original Message-----
Jennifer,

You description refers to 3 macros, but it is not clear what the
relationship is between them. Are they all supposed to be part of a
macro group, or are they in fact in each of 3 separate macros. How are
they being run... are each of them run individually, or is there a
RunMacro action in a 4th macro, as has been suggested elsewhere in this
thread, that is supposed to cycle through all three of these existing
ones? Why haven't you just put all of these actions into one macro... I
can't see any reason why they need to be split into 3 macros at all?

--
Steve Schapel, Microsoft Access MVP
I am still having a problem making it work. I am able to
get through two of the macros, but the third one does not
work correctly.

This is what I have so far:

Macro Name: mcrOnOpen
Condition: {blank}
Action: {blank}

This macro maximizes the form window:

Macro Name: {blank}
Condition: {blank}
Action: Maximize (This part works fine.)

This macro opens up a text box to enter in a country name
if outside the United States. "00" indicates a country
oustide the U.S.:

Macro Name: {blank}
Condition: [State]<>"00"
Action: SetValue
Item: [Forms]![frmIDandContactInfo]![SpecifyCountry].
[ColumnHidden]
Expression: True

Macro Name: {blank}
Condition: [State]="00"
Action: SetValue
Item: [Forms]![frmIDandContactInfo]![SpecifyCountry].
[Visible]
Expression: True

Macro Name: {blank}
Condition: ...
Action: StopMacro

Macro Name: {blank}
Condition: {blank}
Action: SetValue
Item: [Forms]![frmIDandContactInfo]![SpecifyCountry].
[Visible]
Expression: False

Macro Name: {blank}
Condition: [SpecifyCountry] Is Not Null
Action: SetValue
Item: [Forms]![frmIDandContactInfo]![SpecifyCountry]
Expression: Null {This macro also works fine.)

The following macro opens up a text box to enter in the
source of a phone number if a number is entered in
under "Other Phone". THIS MACRO ONLY WORKS IF THE TEXT
BOX FOR [STATE]<>"00". IT DOES NOT WORK IN INSTANCES
WHERE [STATE]="00".:

Macro Name: {blank}
Condition: [OtherPhone] Is Null
Action: SetValue
Item: [Forms]![frmIDandContactInfo]! [SpecifyOtherPhone].
[ColumnHidden]
Expression: True

Macro Name: {blank}
Condition: [OtherPhone] Is Not Null
Action: SetValue
Item: [Forms]![frmIDandContactInfo]! [SpecifyOtherPhone].
[Visible]
Expression: True

Macro Name: {blank}
Condition: ...
Action: StopMacro

Macro Name: {blank}
Condition: {blank}
Action: SetValue
Item: [Forms]![frmIDandContactInfo]! [SpecifyOtherPhone].
[Visible]
Expression: False

Macro Name: {blank}
Condition: [SpecifyOtherPhone] Is Not Null
Action: SetValue
Item: [Forms]![frmIDandContactInfo]![SpecifyOtherPhone]
Expression: Null

Macro Name: {blank}
Condition: {blank}
Action: StopMacro

END OF MACROS

If "00" is entered under [State], then no text box will
open to specify the source of a number entered into
[OtherPhone]; however, if anything other than "00" is
entered under [State], then the third macro works just
fine. I'm sure that there is something wrong with one of
my conditions, but I'm new at this and can't figure it
out. Each macro works separately on its own. (Note:
When the second macro stand alone, it ends with a
StopMacro action. If I enter this action in the group of
macros, the third macro shuts down altogether.

I would really appreciate any further input you might be
able to provide!

Thanks!

Jennifer
.
 
Jennifer
but the third one breaks (i.e., it only functions if
anything other than "00" is entered in the [State] field.

This is because you have a StopMacro action, which is activated if
[State]="00", and so if [State] is not "00" the macro does not proceed
past this point, and therefore any subsequent actions are not processed.
 
Steve,

I have eliminated the StopMacro line from my macro and the
third action works, but now when I enter in "00" for the
[State] field, no text box opens. What do I need to add
to make this work?

Jennifer
-----Original Message-----
Jennifer
but the third one breaks (i.e., it only functions if
anything other than "00" is entered in the [State]
field.

This is because you have a StopMacro action, which is activated if
[State]="00", and so if [State] is not "00" the macro does not proceed
past this point, and therefore any subsequent actions are not processed.
 
Jennifer,

Ok, I should have done this a long time ago... I am very sorry, I can't
really understand what your existing macro is supposes to achieve. Can
you please explain in ordinary English what you actually want to happen
with this form? For example, if you enter 00 in the State textbox, what
is supposed to happen? And so on. Thanks.
 
So here's the gist of it:

I have a few combo boxes with an "other" option. So, if I
enter in "other" I would like a text box to open to
describe what "other" is. In the State example, if the
client lives in the United States, then the two-letter
postal abbreviation ("AL","MN", etc.) will be entered. If
they live outside of the U.S., then "00" is entered. In
this instance, I would like a text box to open to specify
the country.

My next instance of an "other" (although this is for a
text box and not a combo box) involves a phone number that
is not a home or work phone number. This field is called
OtherPhone. In this case, if, and only if, a number is
entered into this field, I would like a text box
(SpecifyOtherPhone) to open to describe the source of the
phone number (mobile phone, etc.). If the field is left
blank, then I would like SpecifyOtherPhone to remain
hidden and to have the cursor move to the next field.

I can get each of these to work separately. For instance,
if I attach the State macro to the OnCurrent event, and
the OtherPhone macro to the OnOpen event, they will work
fine. My ultimate goal, though, is to have all of
these "other"-type combo and text boxes in one macro
attached to the OnCurrent event. This is where I'm having
difficult programming the macro.

I would really appreciate any ides and suggestions you may
have.

Thanks!

Jennifer

-----Original Message-----
Jennifer,

Ok, I should have done this a long time ago... I am very sorry, I can't
really understand what your existing macro is supposes to achieve. Can
you please explain in ordinary English what you actually want to happen
with this form? For example, if you enter 00 in the State textbox, what
is supposed to happen? And so on. Thanks.

--
Steve Schapel, Microsoft Access MVP

Steve,

I have eliminated the StopMacro line from my macro and the
third action works, but now when I enter in "00" for the
[State] field, no text box opens. What do I need to add
to make this work?

Jennifer
.
 
Jennifer,

Ok, thanks for the clarification. It seems to me, therefore, that the
macro on the form's Current event, would be like this:

Macro Name: {blank}
Condition: [State]<>"00"
Action: SetValue
Item: [SpecifyCountry].[Visible]
Expression: No

Macro Name: {blank}
Condition: [State]="00"
Action: SetValue
Item: [SpecifyCountry].[Visible]
Expression: Yes

Macro Name: {blank}
Condition: ...
Action: SetValue
Item: [SpecifyCountry]
Expression: Null

Macro Name: {blank}
Condition: [OtherPhone] Is Null
Action: SetValue
Item: [SpecifyOtherPhone].[Visible]
Expression: No

Macro Name: {blank}
Condition: ...
Action: SetValue
Item: [SpecifyOtherPhone]
Expression: Null

Macro Name: {blank}
Condition: [OtherPhone] Is Not Null
Action: SetValue
Item: [SpecifyOtherPhone].[Visible]
Expression: Yes

I hope I have got a general handle now on what you want.
 
Steve,

Thank you!!! It is now working perfectly! I really
appreciate your time and patience with this.

Jennifer
-----Original Message-----
Jennifer,

Ok, thanks for the clarification. It seems to me, therefore, that the
macro on the form's Current event, would be like this:

Macro Name: {blank}
Condition: [State]<>"00"
Action: SetValue
Item: [SpecifyCountry].[Visible]
Expression: No

Macro Name: {blank}
Condition: [State]="00"
Action: SetValue
Item: [SpecifyCountry].[Visible]
Expression: Yes

Macro Name: {blank}
Condition: ...
Action: SetValue
Item: [SpecifyCountry]
Expression: Null

Macro Name: {blank}
Condition: [OtherPhone] Is Null
Action: SetValue
Item: [SpecifyOtherPhone].[Visible]
Expression: No

Macro Name: {blank}
Condition: ...
Action: SetValue
Item: [SpecifyOtherPhone]
Expression: Null

Macro Name: {blank}
Condition: [OtherPhone] Is Not Null
Action: SetValue
Item: [SpecifyOtherPhone].[Visible]
Expression: Yes

I hope I have got a general handle now on what you want.

--
Steve Schapel, Microsoft Access MVP

So here's the gist of it:

I have a few combo boxes with an "other" option. So, if I
enter in "other" I would like a text box to open to
describe what "other" is. In the State example, if the
client lives in the United States, then the two-letter
postal abbreviation ("AL","MN", etc.) will be entered. If
they live outside of the U.S., then "00" is entered. In
this instance, I would like a text box to open to specify
the country.

My next instance of an "other" (although this is for a
text box and not a combo box) involves a phone number that
is not a home or work phone number. This field is called
OtherPhone. In this case, if, and only if, a number is
entered into this field, I would like a text box
(SpecifyOtherPhone) to open to describe the source of the
phone number (mobile phone, etc.). If the field is left
blank, then I would like SpecifyOtherPhone to remain
hidden and to have the cursor move to the next field.

I can get each of these to work separately. For instance,
if I attach the State macro to the OnCurrent event, and
the OtherPhone macro to the OnOpen event, they will work
fine. My ultimate goal, though, is to have all of
these "other"-type combo and text boxes in one macro
attached to the OnCurrent event. This is where I'm having
difficult programming the macro.

I would really appreciate any ides and suggestions you may
have.

Thanks!

Jennifer
.
 
Jennifer,

You are welcome! I am very pleased to know that it's sorted now.
However, I hope you can also look back over your original macro design,
and see if you can figure out what wasn't working.
 
Back
Top