MsgBox Function

  • Thread starter Thread starter J. Adams
  • Start date Start date
J

J. Adams

Hi,

We have just made the jump from Access 97 to Access 2002.
One thing I would do with msgbox's in 97 was bold certain
lines of text in the msgbox by using the "@" character in
the message text. When testing 2002 I noticed that this
is no longer working, so I guess 2002 doesn't allow you
to do this (at least by using the 97 method?). I have
been going through help to see if I can find out if it
can be done in 2002 but have had no luck. So my question
is obvious: Can bolding text in a msgbox still be done in
2002, if so, how do I do this?

Thanking you in advance..

J. Adams
 
I know this works in Access 2000, so:

eval("Msgbox(""This line is bolded@This line isn't@This
line isn't either"",0 ,""Testing Eval Function"")")


It didn't seem to like the vbmsgbox constants, so just
replace them with the numbers.

Chris Nebinger
 
try searching google with the following criteria

Msgbox bold text 2000 group:microsoft.public.access.*

It should bring up a way to do this using code. I think you could add Author
Graham Seach to the search string to pare the results down a bit
 
Try this:

Public Function FMsgBox(sLine1 As String, sLine2 As String, _
sLine3 As String, Optional lButtons As VbMsgBoxStyle = vbOKOnly, _
Optional sTitle As String = vbNullString, Optional HelpFile As Variant,
_
Optional Context As Variant) As VbMsgBoxResult
'
'Description: This function creates a formatted MsgBox
' similar to that which was available in Access 97 and
' earlier versions.
'
'Inputs: sLine1: The first line of text to be displayed.
' sLine2: The second line of text to be displayed.
' sLine3: The third line of text to be displayed.
' lButtons: The buttons to be displayed (exposed
' as a vbMsgBoxStyle enum).
' Title: The (optional) MsgBox title.
' HelpFile: The (optional) help filename.
' If HelpFile is supplied, then Context
' must also be supplied.
' Context: The (optional) context or topic ID.
'
'Outputs: The standard MsgBox return value.

Dim sPrompt As String

'All three lines must exist
If Len(sLine1) > 1 And Len(sLine2) > 0 And Len(sLine3) > 0 Then
sPrompt = sLine1 & "@" & sLine2 & "@" & sLine3

If IsMissing(HelpFile) Or IsMissing(Context) Then
FMsgBox = Eval("MsgBox(""" & sPrompt & """, " _
& lButtons & ", """ & sTitle & """)")
Else
FMsgBox = Eval("MsgBox(""" & sPrompt & """, " _
& lButtons & ", """ & sTitle & """, """ _
& HelpFile & """, " & Context & ")")
End If
Else
DoCmd.Beep
MsgBox "You must supply all three lines.", _
vbOKOnly + vbExclamation, "Argument missing"
End If
End Function

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html
 
-----Original Message-----
Try this:

Public Function FMsgBox(sLine1 As String, sLine2 As String, _
sLine3 As String, Optional lButtons As VbMsgBoxStyle = vbOKOnly, _
Optional sTitle As String = vbNullString, Optional HelpFile As Variant,
_
Optional Context As Variant) As VbMsgBoxResult
'
'Description: This function creates a formatted MsgBox
' similar to that which was available in Access 97 and
' earlier versions.
'
'Inputs: sLine1: The first line of text to be displayed.
' sLine2: The second line of text to be displayed.
' sLine3: The third line of text to be displayed.
' lButtons: The buttons to be displayed (exposed
' as a vbMsgBoxStyle enum).
' Title: The (optional) MsgBox title.
' HelpFile: The (optional) help filename.
' If HelpFile is supplied, then Context
' must also be supplied.
' Context: The (optional) context or topic ID.
'
'Outputs: The standard MsgBox return value.

Dim sPrompt As String

'All three lines must exist
If Len(sLine1) > 1 And Len(sLine2) > 0 And Len (sLine3) > 0 Then
sPrompt = sLine1 & "@" & sLine2 & "@" & sLine3

If IsMissing(HelpFile) Or IsMissing(Context) Then
FMsgBox = Eval("MsgBox(""" & sPrompt & """, " _
& lButtons & ", """ & sTitle & """)")
Else
FMsgBox = Eval("MsgBox(""" & sPrompt & """, " _
& lButtons & ", """ & sTitle & """, """ _
& HelpFile & """, " & Context & ")")
End If
Else
DoCmd.Beep
MsgBox "You must supply all three lines.", _
vbOKOnly + vbExclamation, "Argument missing"
End If
End Function

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd- 0764559036.html





.
Thanks for the code Graham.. Although it works I find
it incredibly stupid that you have to go through that to
do what you could simply do by adding the "@" character
at the end of the string in Access 97's msgbox function.
Also, you didn't have to give three lines of text for it
to work in 97, you could simply use "@@" at the end of a
line. In my opinion this is definitely not an improvement
from 97. Oh well, thanks again for your help, I'll hold
a vegemite sandwich to the sky in your honour..
 
the vbmsgbox constants can be used if you wrap them in "'s

e.g. ...isn't either"", " & VbMsgBoxStyle & ",""test....
 
Back
Top