Contents in short

  • Improvement / Replacement / better VBA msgbox 
  • Works on MS Access 2007/2010/2013/2016 for 32bit and 64bit
  • Creative Commons Attribution License 3, MS Access VBA, accdb

ContactDownload at the bottom of the page

Improved, Enhanced Message Box Replacement for MS Access

This project provides a custom and enhanced message box replacement for the default MsgBox found in Access.

A accdb demo database with a Your-Code-Wizard containing all the code for Access 2007/2010/2013/2016 for 32bit and 64bit is available below!

This is not a tool I created myself, but I put quite some work into improving it. I tried to contact the original developer Renaud Bompuis and made the update available to him, but I also wanted to make sure it's available from here.

Renaud explains very good how easy it is to replace the original msgbox with his dialog.box or dialog.richbox - the latter displaying Access richt text format.

The improvements I made over his original 1.10 version are documented at the bottom of this page in detail. 

You can download the demodatabase in accdb format here. If you change anything, especially improve the code, please send me an update. Also make sure to leave credits and links to Renauds and my page in the code.

Installation

You need to grab all files from the file you download and copy them into your own application (there is another module in the demo database - compared to Renaud's version)!

Features

So let's see what the improved version can do for you. In the first picture you see the base form of the tool. I redesigned it a little to make room for the features which include:

  • Page Your Code Button where the Your-Code-Wizard generates code for the button you just created, so that you can Copy&Paste it directly into your modules! This means, the original form not only works as a demo, but also helps you to create beautiful buttons even with rich text (RTF) messages!
  • Custom Default Button: It seemed a good idea to me not always to use the standard default button (opened dropdown in image) but to make it cusomizeable! You can decide which of the three buttons should be the default button.
  • The new default button feature goes along with the AutoCloseSec option: After the buttons are being enabled the AutoCloseSec options starts a countdown with the length of the value of this option. Once the countdown is down to zero, the dialogbox (messagebox) will close automatically, returning the/your default button!
  • The Avoid Long Wizard-Text-Code checkbox helps you, in case the Your-Code-Wizard has too many linebreaks (too many for VBA). Just enable the checkbox and your messagetext will be created in a single line so that there should be no problems copying the Your-Code-Wizard code to your own VBA module.
  • Custom Buttons are nice, but custom color buttons are nicer! Look at the screenshots below as well: You can easily set a color for each of the buttons (even if not vbCustom)! Simply enter RGB values and you are done. The buttons now have a hand symbol when you hover them and they get a hover effect!
  • Do I need to mention, that the standard MsgBox buttons will not create some Your-Code-Wizard code?
  • Also: Everything Renaud writes in his blog about his tool concerning implementing it in your own project is still true: You can run a search (msgbox) and replace (with dialog.box)! You can also still run a correct msgbox "my test message",vbOKOnly,"This is the title" as dialog.box "my test message",vbOKOnly,"This is the title" - no need to use the Your-Code-Wizard! 

Custom Default Button

This is what the buttons can look like now. First image shows button 1 to be the (system)default, the second image shows the middle button (button 2) to be the (custom)default. In both images you can see the number in brackets (3) and (2) - which are the AutoCloseSeconds remaining before the specific button will be "pressed".

EnhancedMessageBox_50_CustomButtonsCountdownD3.png EnhancedMessageBox_51_CustomButtonsCountdownD2.png

In the upper part of the next image you see the Your Button Code page open, showing the code that can be copied and pasted into your application! A little side note: The code might look ugly in this preview, but looks very nice in your code window! You can see the wizard created code below this image.

EnhancedMessageBox_08_YourCodeWizard.png

Your-Code-Wizard from one of the dialog boxes above - ready to copy&paste:

'Your-Code-Wizard by http://www.datenbank-projekt.de
strResult = Dialog.RichBox(Prompt:= "<div><font size=3 color=""#808080""><strong>Too late for boarding</strong></font></div><p/>You flight <font face=Consolas style=""background-color:#FFFF00"">BA5584</font> has already left the runway.<br/>It 's a bit too late to run after it.<p/><p/>Would you like to book another flight?" & "", _
    Buttons:=(1024+64), _
    Title:="Enhanced Message Box", _
    LabelButton1:="Button1", _
    LabelButton2:="thisDefault", _
    LabelButton3:="Button3", _
    DismissID:="", _
    AutoCloseSec:=3, _
    DefaultButton:=0, _
    BGColorButton1:= RGB(200,200,225), _
    BGColorButton2:= RGB(100,225,100), _
    BGColorButton3:= RGB(225,100,100), _
    AllowBeep:=False, _
    AllowCopyToClipboard:=False, _
    AllowSaveToFile:=False, _
    NoStrEsc:=False)

Download here

Suggestions? Questions? Wishes?

Please let me know using the contact form.

Updates I made from the original 1.10 version

  • version 1.12b  Olaf Nöhring, http://www.datenbank-projekt.de
    • made tool working on access 32 and 64 bit
    • added IsBlankEMB to script for testing of empty/null variables
  • version 1.13, 1.14       Olaf Nöhring, http://www.datenbank-projekt.de
    • added AutoCloseOption with countdown on default button
  • version 1.15   Olaf Nöhring, http://www.datenbank-projekt.de
    • added custom default button option
    • added box title
    • added Your Button Code / Code-Wizard page for easy copy&paste
    • made UnEscStr public function to be used in form as well
    • added test if default button is visible, if not set new default button
    • added backgroundcolor option for each button
    • added hover effect for buttons
  • version 1.16   Olaf Nöhring, http://www.datenbank-projekt.de
    • corrected richbox default bgcolor of buttons