Macros

A

Ali

I have grouped my macros into one macro. The grouped
macro will open a selected query. Problem - when I
select one of my queries in my list box only the first
macro in my group executes. How do I get the macro to
run for the query I click on and not only the first query
listed in the group?
 
K

Ken Snell

Likely you need to use some Condition statements in the macro that use the
value of the listbox in some way.

Can you post more info about the macros themselves?
 
G

Guest

Sure - I have twelve macros (each one says OpenQuery,
MsgBox, Close). These twelve macros are then grouped
into one macros that says RunMacro - there are 12
RunMacros all of different names). When I run the
grouped Macro only the first one executes. I hope this
is helpful?
 
T

tina

as Ken said, you need to set a condition for each macro
action, as

Condition Action Argument
If ListBoxName = "x" OpenQuery QueryName
.... MsgBox message text
If ListBoxName = "y" OpenQuery QueryName
.... MsgBox message text
If ListBoxName = "z" OpenQuery QueryName
.... MsgBox message text
and so on, ending with
Close

the ellipse (...) tells the system to run that action
after the previous condition has been met, so you don't
have to put the same condition on consecutive lines.

if your message box has the same text regardless of which
query is selected, you only have to put the MsgBox action
once (without an ellipse) right before the Close action.

hth

ps. i made neat columns above, but i'm sure they'll be
messed up in the post. hope it's not too confusing. :)
 
K

Ken Snell

From your description, I am not sure of just what you have in the macro. Is
it that you have one macro with twelve steps, such as this:

macMacro
Action: OpenQuery
Query Name: name1
Action: OpenQuery
Query Name: name2
(etc.)


Or, do you have twelve macros, each with their own names, such as this:

macMacro
Macro Name: Macro1
Action: OpenQuery
Query Name: name1
Macro Name: Macro2
Action: OpenQuery
Query Name: name2
Macro Name: Macro3
Action: OpenQuery
Query Name: name3
(etc.)


From your description, I'm guessing that it's the second example that I've
shown. Assuming that this is correct, unless you call the macro using the
full syntax macMacro.Macro1, or macMacro.Macro2, etc., then the macro will
run the first "macro name" and then will stop when it sees the next macro
name. So, the fix would be to expand your reference of the macro when you
call it.
 

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