Saturday, November 10, 2007

Formatted MsgBox in Access

I wanted to create a formatted message box in Access, with the first line being bold, to duplicate the built-in delete confirmation message. In older versions of Access, you could use

MsgBox "First line is bold@Second line is normal@@"

but when Access moved from 97 to 2000 this feature went away.

I Google'd this & found several versions of a workaround, and here is what worked for me in Access 2003:

EDIT: 06/19/2008 this replaces the original code:

Function MsgBoxEx(sBoldText As String, sNormalText As String, iButtons As Integer, iIcon As Integer, sTitle As String) As Integer
Dim s As String
s = sBoldText & "@"
s = s & sNormalText & "@@"
MsgBoxEx = Eval("MsgBox(""" & s & """, " & iButtons + iIcon & ", '" & sTitle & "')")
End Function

This function will accept built-in constants for buttons and icons, and will return a value based on the buttons.


Anonymous said...

good info,

The first sorry for my inglish

And the other think is, how can i make the msgbox, I need one msgbox in a date..

For example.. the date is 12/12/09 I need call to may frend in this day, and access need remember..

How can I make for than access show a msgbox in this date..

One more time sorry for my bad inglish, and thanks for you help and your information..

See you

Bill Mitchell said...

Take a look at this link, it shows a basic way to accomplish that. Run the 1st code to set up the alert table, then follow the directions to set up the 2nd code.

Anonymous said...

Thank you very much

Good blog, is in my bookmarks

See you