Flow control

S

souris

Hi All,

Does macro support flow control like "if" statement?
I would like to have my macro have if statement to run different query
depends on the condition.
Is it possible to have macro like this?
If not, are there any work around?
Thanks in advance,

Souris
 
T

tina

yes, you can do something "sorta like" that using a macro. use a conditional
statement to control which query runs, as

Condition: Something is true
Action: OpenQuery
Condition: ... (ellipsis)
Action: StopMacro
Condition: Something else is true
Action: OpenQuery
Condition: ... (ellipsis)
Action: StopMacro

if the first condition is true, the query will open and then the macro will
stop executing. if the first condition is false, the query will not open and
the macro will skip the second action and continue to the next condition,
and the cycle will repeat.

hth
 
S

souris

Thanks for the information,
Can you give me a sample condition?
I got "The text item you entered is not in the list" error when I enter
"..." or a condition.
Where I did wrong here?
Thanks millions,

Souris
 
T

tina

your condition is whatever you want to test for True or False. it's the same
condition you would put in an IIf() function, such as

MyFormControl = a certain value

or

AValue + AnotherValue = ThisTotal

as for the ellipsis (...), you can't use it as the first condition in a
macro. it must always be the condition for an action subsequent to an action
with a Condition statement. suggest you search on "macro condition" in
Access Help, A2003 Help provides a lot of detail about macros and
conditions, including the use of ellipsis; and my guess is that A2000
probably has at least a reasonable amount of info, too.

hth
 
S

souris

Thanks for the information.

I have a control called "text3" on the form design.

I click Macro --> New.
There are 2 columns on the Macro edit form which are Action and Comment.
I tried to type in Text3.Text = 3, but I got "Item is not in the list"
error.

Can you please let me know where I did wrong here?
Thanks millions,

Souris
 
T

tina

open your macro in design view. on the menu bar, click View. on the drop
menu, click on Macro Names and Conditions. now you have all four columns
showing on your macro sheet. go back and read my first post, which is
talking about the Condition and Action columns - it should make more sense
now.

hth
 
S

souris

Thanks millions,

Souris,


tina said:
open your macro in design view. on the menu bar, click View. on the drop
menu, click on Macro Names and Conditions. now you have all four columns
showing on your macro sheet. go back and read my first post, which is
talking about the Condition and Action columns - it should make more sense
now.

hth
 

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