Access Europe User Group - Wed 7 Jan: Spot the Difference – A new style MsgBox for Access (Neil Sargent)

I remember reading somewhere that if you name your message box function MsgBox, it will be used instead of the built-in function. The reason is that VBA modules are search before built-in.

That is correct. It was mentioned in the Access Europe meeting led by Neil Sargent on Wed 7 Jan and is also covered in the articles linked in my last reply.

The same applies to any built-in function - it can be 'overwritten' by your own custom function as Access will always use the custom function by default.

For this to work successfully on existing code, the custom function must have the same arguments of the built-in version and in the same order.
Hence also my comments in point 1 of post #39 of this lengthy thread.
 
Glad I could help.

However, there are a couple of important things you need to be aware of:

1. The optional arguments for the FormattedMsgBox function are in the same order as the standard VBA MsgBox function:
Code:
Public Function FormattedMsgBox(Prompt As String, Optional Buttons As VbMsgBoxStyle = vbOKOnly, _
 Optional Title As String = vbNullString, Optional HelpFile As String = "", Optional Context As Long = 0) As VbMsgBoxResult

However, the arguments for the Wixhook.WizMsBox function are in a different order
Code:
Function WizMsgBox(bstrText As String, bstrCaption As String, wStyle As Long, idHelpID As Long, bstrHelpFileName As String) As Long

Unless you take this into account, all your previous 900+ WixMsgBox messages will not work as you expect after conversion .....
As you might imagine blind panic immediately set in: I had always used the WizMsgBox as though it had the arguments in the MsgBox order and it worked.

Then I did some archaeology in my ancient documentation (2004) and found my own function I which was using - WHMBox - had them in 'proper' order. I had written it when I first discovered WizHook and followed the recommendation of the author's article.

Phew!
 
Last edited:
2. I found out yesterday that the FormattedMsgBox can now produce both styles of message box
The old style with the bold first line is created if you omit the optional HelpFile & Context arguments.
Very interesting, Colin!
I wish the Access team would sort this out and document it accordingly.
Because at the moment, no one knows exactly how long each 'technology' will be supported...
 

Users who are viewing this thread

Back
Top Bottom