Custom Text on MsgBox Buttons

  • Thread starter Thread starter James
  • Start date Start date
How do I make the buttons in a MsgBox have custom text? Thanks!

You can't!

What you can do is create your own unbound form to be used as a
message form.

For example, add a Label control and a Text control as well as 2
command buttons.

You can caption them any way you want.
Name them cmdOK and cmdNo


You can set the font style, size, color, etc., however you wish.

Code the cmdOK button's click event:
TextControlName = 1
Me.Visible = False

Code the cmdNo click event:
TextControlName = 2
Me.Visible = False

You would then open the form, using:

Dim strMessage as String
strMessage = "This is your message. Click CommandOk for Yes or
CommandNo for No."
DoCmd.OpenForm "MessageFormName", , , , , acDialog, strMessage

If forms!MessageFormName!TextControlName = 1 then
' Do the Yes thing
Else
'Do the No thing
End If

DoCmd.Close acForm,"MessageFormName"

Code the Load event of the message box form:
LabelMessageName.Caption = Me.OpenArgs

When the form is opened processing waits (just like a MsgBox) until
you click either command button. Then the OK or No action will be
taken and the form closed.
 
I show how in my May, 2005 "Access Answers" column in Pinnacle Publication's
"Smart Access".

You can download the column (and sample database) for free from
http://www.accessmvp.com/DJSteele/SmartAccess.html

Having said that, I'd actually advise creating your own form that looks like
a message box, rather than relying on the (often tempermental) approach in
that article.
 

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

Create msgbox buttons 4
MsgBox "Coordinates" 4
Creating Custom Error Reports 1
Date Warning MsgBox 2
how to make msgbox ? 3
A better way to close main form? 3
Syntax error 3
Programming "Next Record" 11

Back
Top