Passing OK/Cancel from dialog box to macro

  • Thread starter Thread starter Serena
  • Start date Start date
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
 
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.
 
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 ?
 
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
 
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 !
 
Back
Top