AccessBlog.net

News, links, downloads, tips and tricks on Microsoft Access and related

About Me Search
Alex
Name:Alex Dybenko

Location:Moscow, Russia

Tuesday, September 06, 2005

Bring back Access 97 MsgBox

Old good Access 97 has MsgBox function which allows you to show message box with text, divided into 3 sections, with bolded first. Since Access this functionality gone. But not completely - you can still do the same in macros. Here a workaround how to bring old functionality back. Just add a function below to any module, and all MsgBox start to work like in Access 97:

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 PROC_ERR
If IsMissing(HelpFile) Or IsMissing(Context) Then
MsgBox = Eval("MsgBox(""" & Prompt & """, " & _
Buttons & ", """ & Title & """)")
Else
MsgBox = Eval("MsgBox(""" & Prompt & """, " & _
Buttons & ", """ & Title & """, """ & _
HelpFile & """, " & Context & ")")
End If

PROC_EXIT:
Exit Function

PROC_ERR:
MsgBox = VBA.MsgBox(Prompt, Buttons, Title)
GoTo PROC_EXIT
End Function

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home