MsgBox in Macros?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have no problem by using the MsgBox with Macro, but I've faced the problem
quite often that the @-sign doesn't work as it should be. I understand I can
only use maximum of 2-@ in one MsgBox only. Can anyone please help? thanks,
Karen
 
Karen,
You wrote...
the @-sign doesn't work as it should be.
What is your string, what do you see, and what are you expecting to see?

AAAAAAA @ BBBBBBBBB @ CCCCCCC (in quotes)
The following example displays a formatted message box with a sectioned
message. The first sectiontext (A's) in the message are displayed as a bold
heading. The second section (B's) are displayed as plain text beneath that
heading. The third section (C's) are displayed as plain text beneath the
second section, with a blank line between them.
hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions
 
Thanks for your prompt reply, Al. I did what you stated. The message
displayed just like its typed all the way through, no splitting. As I said,
at times it works for me, at times not, what did I do wrong? By the time it
didn't work for me, I even tried both ways of (1) leaving a space before and
after the @ sign and (2) without a space before and after the @ sign.
 
I am back, sorry to leave last night (2a.m. my time), thanks for all.
I studied the page you referred to. I have to state that I am just an
elementary user, those codes are difficult for me. Yet I am going to try
that out, just one simple question: where you said "add the following to
Access database and call it instead of the VBA MsgBox" - in where shall I
add?
 
Well, I'm not the one who said it: MichKa (Michael Kaplan) is, but what you
have to do is copy the code below and paste it into a module:

Function FormattedMsgBox( _
Prompt As String, _
Optional Buttons As VbMsgBoxStyle = vbOKOnly, _
Optional Title As String = vbNullString, _
Optional HelpFile As Variant, _
Optional Context As Variant) _
As VbMsgBoxResult
If IsMissing(HelpFile) Or IsMissing(Context) Then
FormattedMsgBox = Eval("MsgBox(""" & Prompt & _
""", " & Buttons & ", """ & Title & """)")
Else
FormattedMsgBox = Eval("MsgBox(""" & Prompt & _
""", " & Buttons & ", """ & Title & """, """ & _
HelpFile & """, " & Context & ")")
End If
End Function

When you save the module, make sure you do not name the module
"FormattedMsgBox": you cannot name a module the same as routines that exist
within it.

Once you've done that, change any call to MsgBox to FormattedMsgBox instead
(you can do that easily through the VB Editor using the Edit | Replace
option, also accessible through Ctrl-H)
 
Back
Top