Message Box Formatting (1 Viewer)

JPritch

Registered User.
Local time
Today, 12:56
Joined
Jan 7, 2005
Messages
55
Aside from creating a Popup Form with custom formatting, is it possible to format a MsgBox using VBA? We have set up a number of message boxes, however some of the text is pretty short and we would like to center it within the message box. Also, some of the message boxes look too big for the text that is in them, and we would like to shrink the message boxes a bit.

Possible via VBA?
 

adevera

Registered User.
Local time
Today, 12:56
Joined
Mar 2, 2005
Messages
52
There is no othger way you can alter the appearance of messgax box.

All you have to do is create a form that will act as your message box
 

Ode

Registered User.
Local time
Today, 20:56
Joined
Apr 18, 2005
Messages
10
For a simple Message box (my case), I used a conjunction of newline and spaces to relative success.

MsgBox "____________Blah Blah Blah____________" & vbCrLf & "____________Blah Blah____________"...

where ____________ = spaces

Apart from this, and like adevera mentioned, create a form that will act as your message box.
 

ghudson

Registered User.
Local time
Today, 15:56
Joined
Jun 8, 2002
Messages
6,195
About the only thing you can do with the text is you can bold the top line [section] of your message box using the EVAL function and the @ symbol. Ensure you keep the single quotes and @ exactly like my example. This will work for all versions of Access.

Code:
If (Eval("MsgBox ('Your Bold Text Here.@Your Normal Text Here.@@',20,' Your Title Here')")) = vbYes Then
    MsgBox "user clicked YES"
Else
    MsgBox "user clicked NO"
End If
You will have to play with the aurgument numbers [20] if you need a different symbol and/or buttons.
 

doulostheou

Registered User.
Local time
Today, 14:56
Joined
Feb 8, 2002
Messages
314
Thank you. Your code for the bold formatting was exactly what I needed. I saw that access did this in several places, and I had a hard time believing that it couldn't be duplicated.
 

skea

Registered User.
Local time
Today, 22:56
Joined
Dec 21, 2004
Messages
342
1)In case you want to make a reference to a control on the form and you want your message to break to another line. How do you reformat this.

i.e
Code:
 This is [B]skea[/B] Going 
 To Another Line.
Where skea comes from Me.MyName
 
Last edited:

WayneRyan

AWF VIP
Local time
Today, 20:56
Joined
Nov 19, 2002
Messages
7,122
skea,

MsgBox "This is " & Me.MyName & " Going " & vbCrLf & "To Another Line."

Wayne
 

skea

Registered User.
Local time
Today, 22:56
Joined
Dec 21, 2004
Messages
342
WayneRyan said:
skea,
MsgBox "This is " & Me.MyName & " Going " & vbCrLf & "To Another Line."
Wayne

I meant using the Eval function and the '@' sign.
All i want is modifying ghudson's example in that format but iam Still failing.
Some thing like.
Code:
Eval ("MsgBox('@This is " & "skea" & " going to@    Another Line@@', " & vbInformation & ",'ERROR SIGNAL!')")
So that the name skea comes out bolded.

Logic tells me that the one '@' added to your message text will break the message into paragraphs, with text before the first @ shown in bold. You are limited to three paragraphs with the "@" symbol following each paragraph. If you only want to break for two paragraphs, you must use two @@ symbols at the end of the second paragraph. But how can boldness be placed in the middle of these '@' signs.
Thanks
 
Last edited:

ssteinke

for what it's worth
Local time
Today, 15:56
Joined
Aug 2, 2003
Messages
195
Give this function a try skea... I liked the idea of giving emphasis to some of my msgbox's that I tried to incorporate ghudson's code into this function:

Code:
Function CustomMsgBox(BoldPrompt As Variant, Prompt As Variant, _
                    Optional Buttons As VbMsgBoxStyle = vbOKOnly, _
                    Optional Title As Variant = "Message") As VbMsgBoxResult

    CustomMsgBox = Eval("MsgBox ('" & Replace(BoldPrompt, "'", "") & "@" & _
                                Replace(Prompt, "'", "") & "@@'," & Buttons & ",'" & _
                                Replace(Title, "'", "") & "')")
End Function

i practiced a little and found that you can call it just like you do the regular VBA MsgBox

hope it helps

Scott
 

skea

Registered User.
Local time
Today, 22:56
Joined
Dec 21, 2004
Messages
342
This give me the same thing as ghudson's example.
Any more ideas?
 

ghudson

Registered User.
Local time
Today, 15:56
Joined
Jun 8, 2002
Messages
6,195
Is it worth the effort? Only you can decide that one.

Last resort [more work] would be to create a form to mimick a custom message box. There is a sample somewhere around here that somebody posted for using a form as a message box.
 

skea

Registered User.
Local time
Today, 22:56
Joined
Dec 21, 2004
Messages
342
Thanks
I give up too... This should be some thing in access Wish List. Thanks
 
Last edited:

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 14:56
Joined
Feb 28, 2001
Messages
27,128
Demo-MsgBx contains a fully functioning version of Gramsoft's Multi Purpose MessageBox for Access 2003.
You can use parts of it of the whole package as a module. The command MsgBx can act in 6 different modes

There is a limitation placed on new members. If you tried to post a free example or a free code offering, it didn't work because you are still counted as a new member. Note also that if this evolves into a form of advertising for products to be sold, that such advertising is not allowed.
 

Users who are viewing this thread

Top Bottom