IF/Then Statement in a Macro

B

Beverly76

I would like my macro to lookup a value in a table and if "Y", continue the
macro and if "N", open a form instead. I would like to use this as the
mechanism to redirect users from accessing files at the time they are being
updated.

The table would only have one record with one field that is "Y" or "N".

Please help.
 
K

Ken Snell \(MVP\)

Use the Condition column to handle this:

Condition: DLookup("FieldNameInTable", "TableName") = "N"
Action: OpenForm
< rest of open form arguments >

Condition: ...
Action: StopMacro

Condition: < blank >
Action: < next step of macro to be run if the DLookup function
returns a Y value)

Note the three dots in the second action. Those three dots tell ACCESS that
that step also is to be run if the condition in the previous step is true.
The "blank" entry in the third line's Condition box tells the macro to start
with that step if the condition in the first step is false.
 

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