View Full Version : Good old Acc97 Messagebox


Guus2005
01-21-2010, 11:32 PM
For some reason the old Access 97 (and earlier) message box disappered.
The text was divided into 3 sections, bold first followed by two normal sections. To use the three sections the text/prompt was separated by a @.

Here's a typical message:

msgbox("File not found.@Please locate the file first.@Press ok to continue",vbCritical,"Guus2005")

Alex Dybenko found a way to bring it back to life.

Enjoy!

Public Function MsgBox(Prompt As String, _
Optional Buttons As VbMsgBoxStyle = vbOKOnly, _
Optional Title As Variant = "", _
Optional HelpFile As Variant, _
Optional Context As Variant) As Variant

On Error Resume Next
If Nz(Title, "") = "" Then
Title = CurrentDb().Properties("AppTitle")
End If
On Error GoTo Err_MsgBox

If IsMissing(HelpFile) Or IsMissing(Context) Then
MsgBox = Eval("MsgBox(""" & Prompt & """, " & Buttons & ", """ & Title & """)")
Else
MsgBox = Eval("MsgBox(""" & Prompt & """, " & _
Buttons & ", """ & Title & """, """ & _
HelpFile & """, " & Context & ")")
End If
Exit_MsgBox:
Exit Function
Err_MsgBox:
MsgBox = VBA.MsgBox(Prompt, Buttons, Title)
GoTo Exit_MsgBox
End Function

Source: http://accessblog.net/2005/09/bring-back-access-97-msgbox.html

DCrake
01-21-2010, 11:38 PM
Alex Dybenko may have found a workaround but did not invent it, this is available on the MSKB under FormattedMsgBox. I have been using for quite a while, its only drawback is that if you use it in VB it does not always bring it self to the front but sits on the status bar.

David

Dairy Farmer
09-26-2010, 08:48 PM
I use a very simple way of creating my message boxes. It is slit into 2 parts.

First, what is your message and what style do you want.
Second, what to do with each response.

Dim Msg, Style, Title, Response, MyString
Msg = "Your mesage goes here." & chr(13) &"And some more on a new line."
'Have a look at othe styles you can use
Style = vbYesNo + vbExclamation + vbDefaultButton2
Title = "The bit that is in the title bar"
Response = MsgBox(Msg, Style, Title)
'What happens if you click no
If Response = vbNo Then
MyString = "No"

Dim Cancel As String
Cancel = True

Else
'What happens if you click yes
MyString = "Yes"
'Put some actions in here
End If