msgbox macro

B

_Bigred

Access 2000 (but will be used in access 2003 single machine)

I tried to put a msgbox macro tied to a forms open event, and it worked
fine. But it only gave me the option to click "ok" and no other options.
This was a feable attempt at making a macro that would print ALL reports in
the database after updating info.

Is there anyway to get the yes or no on the msgbox, or should I just create
generic form (set it to dialog box) with the desired buttons?

TIA,
_Bigred
 
K

Ken Snell [MVP]

A MsgBox function has three arguments: message, title, and type/buttons; but
a macro only lets you choose the type and not the buttons. The VBA MsgBox
function makes all of them available to you, but you must use it in the
Condition column as a test, or you must call a VBA function that will run
such a MsgBox function. This latter option would be meaningless for you,
though, because a function cannot return a value to a macro.

So, I assume that you want to test the selection made by the user. So use a
Condition expression, such as this:

6=MsgBox("Do you want to continue?", 32+4+256, "Continue?")

The above condition will return True if the user clicks the Yes button.

For macros, the second argument uses a sum of various numbers to get the
desired buttons and type. 32 is the value for "question" type, 4 is the
value for "show yes and no buttons", 0 is the value to make the first button
be the default choice, and 256 is the value to make the second button be the
default choice. Additionally, 7 is the value returned by the function when
the user clicks the "no" button, and 6 is the value returned by the function
when the user clicks the "yes" button. There are other values available for
use; open the Help window from the database window, go to Contents, go to
Programming in Visual Basic, go to Visual Basic Language Reference, go to
Functions, go to M-P, and click on MsgBox function -- there you'll see the
list of values.
 

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

Similar Threads


Top