New Style Message Boxes with Timeout (6 Viewers)

isladogs

Access MVP / VIP
Local time
Today, 17:03
Joined
Jan 14, 2017
Messages
19,532
The MsgBoxT function has been designed mainly to create new style Fluent UI Access message boxes in Access 365 with a timeout feature.

However, it is a multi-purpose function and can create each of the following message box types with or without a timeout:
• new style Access message box with red header - Access 365 Current Channel (or faster)
• old style Access message box with a bold first line
• standard VBA message box with no formatting.

It also:
• supports Unicode text in the title and message prompt
• supports links to online Help articles / local help files
• adapts to Office theme colours (new style messages only)
• supports use of larger text size and high contrast themes (using Ease of Access features)

Syntax: items in [ ] are optional
MsgBoxT (Prompt, [Buttons], [Title], [HelpFile], [Context], [Timeout])

The MsgBoxT function works by using the Eval function with a standard MsgBox to run the Access Expression Service MsgBox.
The added timeout effect is achieved using 4 Windows APIs

The MsgBoxT function can also be used as a direct replacement for the standard VBA MsgBox function without breaking existing code.
To do so, just rename the function as MsgBox and Access will use the custom function instead of the built-in VBA MsgBox

To use this with your own apps, just import the module modTimedMsgBox
For more details and an explanation of the code used, see my article:

NOTE:
1. Where the message times out, the message box will return the default button value
2. To disable the timeout so it has to be closed by the user, either omit the Timeout argument or set it to 0
3. As with standard message boxes, you can use either message box constants or the numerical values
4. Where no title is specified, the function will use the app name (where present) or default to 'Microsoft Access' - same as standard message boxes
5. Use the 'Line1@Line2@Line3' syntax to split the prompt text into up to 3 separate text blocks
6. The function supports Unicode text in the title and/or prompt
7. The small help button (?) is shown where a valid help file is specified or the context >0.
8. Older versions of Access do not support the new style messages. These are displayed as the old style messages with a bold first line
9. To create the old style Access message boxes in Access 365 (Current Channel or faster) with a bold first line, set Context <0
10. To create a standard message box (with or without a timer, set Context < 0 and omit the'@@' syntax.

Examples:
The following examples were all created in Access 365 using the MsgBoxT function. Most are included in the example app attached

DefaultWithTimeout.png


NewStyleHelpMsg.png


UnicodeMsgEnglish.png


NewStyleLongTitle.png


OldStyleBold.png


StandardMsgTimeout.png


DarkTheme1.png


NewMsgFont150.png


NewMsgHighContrastBlackGreyscale.png


Finally:
Although MsgBoxT has a powerful set of features based on the MsgBox from the Access Expression Service combined with a timeout feature, there are some things it cannot do:

Rich text is not supported by the Access Expression Service
If you need rich text functionality, use an alternative approach such as a custom message form.

Timer countdown isn't supported whilst the timeout feature is running
Access message boxes are modal and therefore static in terms of their contents.
 

Attachments

Last edited:

Users who are viewing this thread

Back
Top Bottom