Passing OK/Cancel from dialog box to macro

S

Serena

Hi there

I am running a macro from a form but partway through the
macro want to pop up a dialog box with a warning message
and options to continue or cancel. How do I do this and
then check which button was clicked in the macro ?

TIA
Serena
 
K

Ken Snell

In the condition box for the macro, type an expression similar to this
(where 1 = OK)

MsgBox("Warning message", 33, "TITLE") = 1

Above will be true if the user clicks the OK button, false if the user
clicks the Cancel button.
 
S

Serena

Sorry, should have mentioned that I'm using Access 97.

Are you saying I should put all of that in the condition
column ? - if not, where do I put the MsgBox command -
macro formats only allow for the specified Action
Arguments if I select the MsgBox Action - where do I put
the 33 ?

Please can you clarify ?
 
K

Ken Snell

You put the expression that I posted in the Conditions column. If it's true,
then the macro will execute the Action.

You don't need a MsgBox action with this.

For example, if you wanted to run a query if the user selects OK (which
would be a true result in the posted expression), your macro would look like
this:

Condition: MsgBox("Warning message", 33, "TITLE") = 1
Action: OpenQuery
 
S

Serena

Thanks Ken, got it now, it must be Monday (in NZ
anyway) ! I also managed to find the help section on
MsgBox which gave all the values - knew I'd seen it
somewhere before but couldn't for the life of me find it
this morning !
 

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