Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2004
    Posts
    20

    Unanswered: MsgBox as a macro condition

    Good day!

    I wrote a function that raises a MsgBox with OK and Cancel buttons. I need a condition in a macro stating if OK was pressed do this if Cancel is pressed do that.

    In MS Access 2002 Help there is an example which doesn't work:
    MsgBox("Confirm changes?",1)=1 that should carry out an action if OK is pressed and ignore it if Cancel is pressed. I have tried it but an error message was raised: "MyDatabaseName can't parse the expression MsgBox("Confirm changes?",1)=1".

    How could I solve the problem?

    Regards!
    BoHr

  2. #2
    Join Date
    Jan 2005
    Posts
    19
    Please learn the value of the messagebox options vbOK, vbOKCancel, vbAbortRetryCancel, vbDefaultButton1, ...
    and vbOK, vbCancel, vbRetry, ... for the result codes.
    This increases readability significantly (and reduces mistakes significantly too).

    Try VB code. Are you using an event? Where are you placing the expression?

    I believe macro's (not VB) also know the MsgBox function, but its different, because it only shows a message with only OK.

  3. #3
    Join Date
    Dec 2004
    Posts
    20
    Hi JDobbelsteen!

    Thanks for your reply!

    I have put the MS Access 2002 Help expression example in the Condition column in my macro and got the error message.

    Don't know how to make use of values from VB in the Condition column of macro. Also, that example from Help is an expression example for macro conditions so should have worked in the Condition column.

    Regards!
    BoHr

  4. #4
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Using the named values for msgbox type will yield a return value like JD stated.

    You can then use:

    If msgbox("yourmessage", sometype) = someNamedValue Then
    etc etc
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  5. #5
    Join Date
    Dec 2004
    Posts
    20
    Hi Teddy!

    Thanks for your reply!

    OK, I'll run macro from VB if condition from MsgBox (OK) is satisfied.

    Big regards to you and JD!
    BoHr

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •