Condition If, Then, Else logic

G

Guest

How do I make conditions in a macro work like an if, then, else type statement?

What I would like to do is have the macro run a query, if the results are
null; follow one set of commands, else if the results are not null follow
another set of commands.

I can make the macro run the query and recognize the condition, but not
choose the path I want it to follow within a macro group.

Any help would be appreciated!
Thank you,
Cathy
 
T

Tom Lake

How do I make conditions in a macro work like an if, then, else type
statement?

What I would like to do is have the macro run a query, if the results are
null; follow one set of commands, else if the results are not null follow
another set of commands.

I can make the macro run the query and recognize the condition, but not
choose the path I want it to follow within a macro group.

You have to put the condition in front of EVERY line you want executed if
the condition is true and the opposite condition in front of every line that
you want executed if the original condition is false. Example, if I want
to do some lines if x>0 and other lines if x not >0:

Tradional BASIC:
If x > 0 then
a=4
b=7
c=2
Else
a=0
b=3
c=6
End If

Macro:
x>0: a=4
x>0: b=7
x>0: c=2
x<=0: a=0
x<=0: b=3
x<=0:c=6

Tom Lake
 
G

Guest

Tom,

My problem is that I'm running a query to check for possible duplicates,
then based on the results of the query I want to run a different query (an
append query) or stop the macro. Neither the append query or the stop
command have the field name in them that I am checking for null.

Another problem I'm having with this process is that I have my warning set
equal to off, but the query that is checking for possible duplicates still
pops up and the macro stops at that point and won't continue.
 
S

Steve Schapel

If an Action in a macro requires the same Condition as the previous
Action, you should put ... in the Condition column, rather than
repeating the Condition expression.
 
S

Steve Schapel

Cathy,

On the basis of what you have told us so far, it seems to me that you
only require one action in your macro, i.e. OpenQuery to run the Append
Query, with a Condition which tests the output of the check duplicates
query. Only guessing here, since I don't know the details of what
you're doing, but possibley the Condition will be something like this...
DCount("*","YourDuplicatesQuery")=0

Sounds like you are actually opening datasheet of the duplicates query
in your macro, which is not appicable.

If you need more help with this, please provide specific details of the
actions in your macro, the details (SQL view for preference) of the
queries, and the details of the condition under which you want the
Append query to run.
 
G

Guest

Steve,

I have tried "..." in the following condition, but it still pops up the
query results, then stops the macro. I've taken the SetWarnings=No, out so
that I could see what exactly the macrogroup is doing... and it still does
nothing until the query results pop up and that ends the macro.

Any other suggestions?
Thanks,
Cathy
 
S

Steve Schapel

Cathy,

As I mentiuoned in my other reply, it is difficult to comment further
without seeing the details of what you're doing. Could you let us know
how your macro and queries are put together?
 

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