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

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...
 
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!

Phew indeed!
It was for that exact reason that my own wrapper function for the WizMsgBox (MsgBoxW) has all the arguments in the same order as the standard VBA MsgBox.
As you want the ‘old style’ messages, have you also confirmed that none of your message boxes include the HelpFile and 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...

Yes I agree but I can’t see them doing so after all this time. Nevertheless it’s something I’m planning to raise with other MVPs and the Access team once I’ve completed the second article.
 
Phew indeed!
It was for that exact reason that my own wrapper function for the WizMsgBox (MsgBoxW) has all the arguments in the same order as the standard VBA MsgBox.
As you want the ‘old style’ messages, have you also confirmed that none of your message boxes include the HelpFile and Context arguments?
Have never needed to use Helpfile and Context (thankfully), but thanks for the warning.
 
I've only rarely used them with my FormattedMsgBox which is why I hadn't previously spotted the difference in behaviour when these were used.
Neil & I have been exchanging emails for several days about the various permutations of Eval, FormattedMsgBox & WizMsgBox and I hope to cover all of these issues in my series of articles.

The next challenge may be to achieve similar results in other Office apps such as Excel, Word
 

Users who are viewing this thread

  • Back
    Top Bottom