Enhanced MsgBox Instructions
-
Upload
joseph-strickland -
Category
Documents
-
view
97 -
download
0
Transcript of Enhanced MsgBox Instructions
MS Access Enhanced Message Box Replacement
This project provides a custom and enhanced message box replacement for the defaultMsgBox found in Access A Test database for Access 2007 is available at the bottom of this
post (Updated Tuesday 17MAR2009)
Whatrsquos wrong with the default MsgBox
The default message box in Access is sometimes useful to warn inform or ask confirmation from theuser
It has however a few drawbacks
It is bland the standard message box does not even follow the currently selected Office 2007schemeThe amount of text it can display is limited if you try to display too much text it will be truncatedYou canrsquot copy or save the content of the messageBecause popup boxes are viewed as intrusive people tend not to read them and end-up closingmessage boxes before they realize they may have contained useful informationThey only displays plain text you cannot format the message to draw attention to the key pointsThey are blocking meaning that nothing can happen in the main application while the box isdisplayed (it canrsquot even shut down)
Sometimes you need to display an important message or require users to make take a decisionMessage boxes are not to be abused but they serve a useful purpose
An enhanced message box
Rather than using the bland standard message box you can now have something a bit more customized
Plain Text version of the enhanced custom message box under the Office Blue Colour Scheme
Tuesday May 20 2008
RichText version of the enhanced custom message box under the Office Black Colour Scheme
Here are the features of the enhanced message box
It is entirely compatible with the standard one just change MsgBox to Box using find and replace
should be enough (see tip below to avoid getting strange errors)It allows the user to simply click on a button to copy the content of the message to the clipboard orsave it to a text file to a configurable default locationIt looks and feels like it belongs to the main application following its colour schemeIt attempts to prevent users from blindly closing the modal box reading the message buttons will firstbe inactive for a configurable amount of time Itrsquos not a perfect solution but it is quite effectiveThere is a RichBox version that can display rich HTML content not just plain text so important parts
of the message can be formatted in a useful wayIt is able to display large amount of data While itrsquos not something you usually want it may be usefulfor the message box to display more text in some situations (log or tracing information legaldocumentation etc)Rather than sprinkling your code with ldquo amp vbCrLf amp _ rdquo uglies you can embed newlines in the text itself
by using C-style ldquo n rdquo escape sequences that will automatically be transformed into the appropriate
newlines Makes for clearer code and less typingBecause you get the source you can easily customise the message box with new icons and colours tobetter match your overall applicationrsquos personalityIt is non-blocking if your application forces users to log-off after a certain amount of inactivity theenhanced message box will just close rather than prevent Access from shutting down like thestandard MsgBox does Of course itrsquos up to you to decide how to handle that gracefully if at all
It properly displays the expected button captions based on the language of the operating system so itbehaves very much like the default MsgBox (for instance it will properly display ldquoCancelrdquo on English
systems and ldquoAnnulerrdquo on French ones)It also properly plays the system sounds associated with the type of message You can also enable ordisable the sound effect as needed
How to use it
Download the demo below and copy (drag amp drop) the following into your application
the FormDialog form
the API_GetTextMetrics module
the Dialog module
If you rename the FormDialog make sure you replace any occurrence to it in the code in particular in the
Dialog module
Since the enhanced message box is just a replacement for the standard one you just use it like youwould use the MsgBox
There are a few additional settings that can be used to change the behaviour of the enhanced messageboxesOne is that you can adjust the delay before the buttons become activated
Another one is that you can enable or disable whether beeps should be played or not
The last settings is the folder where we should save the content of the message when the user clicks theSave button on the message box
view plain copy to clipboard print
----------------------------------------------------------------------------- Simple use of the Plaintext box Note the use of n that will be converted into a newlineDialogBox This is a plaintext messagenClick OK to dismissvbOKOnly+vbinformation _Message Title----------------------------------------------------------------------------- Getting the result backDim dr as vbMsgBoxresultdr = DialogBox(Are you sure you want to delete _vbYesNoCancel+vbQuestion Confirm action)if (dr = vbYes) then DeleteRecords----------------------------------------------------------------------------- Using named parametersDialogBox Prompt=All your bases are belong to us _Buttons=(vbOkOnly+vbCritical) _Title=Bad error----------------------------------------------------------------------------- Using the RichBox to display simple HTML The first line will be bold then the word button will be printed in red Here the n will be escaped to ltbrgt tags to simulate newlinesDialogRichBox ltstronggtThis is a bold messageltstronggtn amp _Click the ltfont color=FF0000gtbuttonltfontgt to dismissvbOKOnly+vbinformation _RichText Message Title
view plain copy to clipboard print
----------------------------------------------------------------------------- Use the ButtonDelay to specify the time in seconds before the buttons become activated The default is 2s Use 0 to activate the buttons immediatelyDialogBox Prompt=All your bases are belong to us _Buttons=(vbOkOnly+vbCritical) _Title=Bad errorButtonDelay=1----------------------------------------------------------------------------- Change the default delay value To disable the activation delayDialogDefaultButtonDelay = 0 To make the user wait 3 seconds before they can press any buttonDialogDefaultButtonDelay = 3
view plain copy to clipboard print
----------------------------------------------------------------------------- Use AllowBeep to specify whether beeps should be played when the message box opens By default they areDialogBox Prompt=All your bases are belong to us _Buttons=(vbOkOnly+vbCritical) _Title=Bad errorAllowBeep=false----------------------------------------------------------------------------- Change the default behaviour This is true by defaultDialogDefaultAllowBeep = false
view plain copy to clipboard print
----------------------------------------------------------------------------- Change the save folder By default the text messages will be saved in the same directory as the database Here we want them to be saved to a temp directory
These few settings make the enhanced message box more customizable
Large text
The standard MsgBox cannot display much text On the other hand there is no real limitation to the
amount of text the Box and RichBox can display
When the amount of information is too much to fit the maximum allowed size for the message box thetext will overflow and can be scrolled updown as necessary
Limitations of the RichBox
The RichBox version relies on the normal TextBox controlrsquos ability under Access 2007 to display RichText
wich is nothing more than lightweight HTMLBecause font size may be varying a lot in the message it becomes very difficult to accurately predict thesize of the box needed to display the whole messageShort of implementing a complete HTML engine we have to rely on some assumptions to display HTMLThe risk is that sometimes the content may not properly fit the TextBox control in some circumstancesIf you use the RichBox thoroughly try displaying your messages and tweak the HTML as necessary to
include additional lines or non-breaking spaces to ensure that the result looks goodIf you donrsquot overuse font size and donrsquot display in multiple fonts the RichBox should do the right thing
most of the timeDonrsquot overuse the RichBox to display colourful messages There is a fine line between being informative
and tasteless Keep colours and formatting where it is usefulI think that in most cases the plain text version Box is more than enough
Replacing MsgBox in existing code
As I said above replacing the standard MsgBox is easy but you need to make sure your search and
replace parameters are configured correctly
If yoursquore getting strange compile errors it may be because you forgot to tick the Find Whole Word Onlyand some of the strings containing the letter sequence ldquomsgboxrdquo were replaced in the process
If thatrsquos the case you can revert the damage by simply doing a search and replace across the wholeproject on- VbboxStyle or VbDialogBoxStyle to be replaced with VbMsgBoxStyle
- VbboxResult or VbDialogBoxResult to be replaced with VbMsgBoxResult
How it works
The code makes extensive use of Win32 API callsMost of the hard work is done in the FomDialog class form There is too much there to really go into the
details but you are welcome to have a look at the commented code
DialogDefaultSavedTextFileFolder= Ctemp
The code relies also on a utility function from Stephen Lebans used to calculate the size of of text I havemade some minor modification to that code so I would refer you to his original implementation if you areinterested in calculating TextBox sizes for forms or reports
In the code for the FormDialog I re-implement some of the expected functionalities of the MsgBox
proper arrangement of the buttons displaying of the appropriate icon etcOnce this is done we calculate the size of the textbox needed to display the whole of the messageIn the case of RichText we first use ApplicationPlainText() to convert the HTML into properly
formatted plain text We then calculate the Textbox size using a slightly larger font than needed as a wayto ensure that the content of the RichText message will fit the box in most casesOnce we know the size of the TextBox we can easily resize the form to properly display the TextBoxIf there is too much text we resize the form to its maximum permissible (70 or screen width and 90of screen height) and change some of the visual cues to let the user know the text is overflowing
One thing of note is the way the form is kept modalRather than using DoCmdOpenForm and DoCmdClose I use the form as a class and create an instance
manually (see the code in DialogBox and DialogRichbox ) I keep this instance alive until I got the formrsquos
result backIf you are interested in knowing how the form is made modal this is the code in FormDialogShowModal()
what keeps the form open until the user clicks a button
The Sleep() function is a Win32 API that stops the current process for the given number of milliseconds
This in effects hands back the control to the Operating System for a short time That way the system isstill responsive and does not consume resources when itrsquos just waiting for user input
Sample database
You can download a sample database containing all the necessary code as well as a number of testsThis version only contains the database in Microsoft Access 2007 accdb format
view plain copy to clipboard print
01 Public Function ShowModal() As VbMsgBoxResult02 03 Here we reset the result for the clicked button such as vbOK vbYes etc04 This is set in each Buttons Click event05 m_Result = -106 Wait for the user to click a button07 Do While (m_Result = -1)08 DoEvents09 Sleep 5010 Loop11 ShowModal = m_Result12 End Function
Download the EnhancedMsgBox01zip (116KB) v13 containing the ACCDB database
Code Updates
v13 17MAR2009Thanks to Henry of Access-Prode for proposing a correction to the default buttons behaviour
Updated behaviour for the default buttons They are now focused in a way that matches that of thestandard msgboxReversed the naming of the buttons on the form to make it a bit more consistent with the standardbox
v12 07SEP2008Thanks to Andy Colonna (httpwwwpcesoftcom) for uncovering the following bugs (check out his freeSpell Checker with source code)
Corrected bug in Form_FormDialogFilenameSanitize() function that would fail to remove all invalid
characters for a file nameFile name for the saved text message will be truncated to first 32 characters of message box title inForm_FormDialogMakeFriendlyFileName()
Changed the use of FollowHyperlink to ShellExecute to avoid security warningin some instances inForm_FormDialogbtCopyToFile_Click()
Corrected twips to pixel conversion bug in API_GetTextMetricsfTextWidthOrHeight() that would result
in an improperly sized dialog box when the text message was too wide
v11 08AUG2008
Corrected code for DefaultButtonDelay (thanks to Geoffrey) (was referencingwrong variable causing
self-referencing code)Corrected code for Box and RichBox to take the DefaultSavedTextFileFolder into account (the path
was previously not passed onto the dialog boxes and the text file would always be created in theapplication folder instead of the one specified by DefaultSavedTextFileFolder )
Added license notice at top of source code
v10 20MAY2008
Original version
Resources
Dissecting the MessageBox article on CodeProjectXMessageBox -- A reverse-engineered MessageBox() article on CodeProjectTextWidth-Height code demo from Stephen Lebans (great resource check it out)Pixel to Twips conversion from MSDNCopy Text to Clipboard from the excellent site The Access WebGetting Resource Strings and more from DLLs
This work is licensed under a Creative Commons Attribution 30 Unported LicenseFree for re-use in any application or tutorial providing clear credit is made about the origin of the codeand a link to this site is prominently displayed where end-users can easily access it
Entry Filed under NetBusinessDatabaseMSAccessProgramming
59 Comments Add your own
WAO
i cannot say more this is extremely good
i saw other solutions but yours surpass all others congratulations
keep on doing the good work
1Edwin Blancovitch | June 5th 2008 at 500 am
Thank you EdwinThere are plenty more that Irsquod like to do just a matter of finding the timehellip
2Renaud | June 7th 2008 at 404 pm
Simply smart Thank you Sir
3 Marvin | June 30th 2008 at 200 pm
Simply fantastic great work thank you
4 Anon | June 30th 2008 at 1159 pm
Renaud
Your website was a real find I love the enhanced message box utility for Access as well as the modaldialogs with transparent backgrounds These are awesome tools that help Access developers tocreate interfaces that have some visual appeal Thanks so much for your efforts and generosity
Ken Warthen
5 Ken Warthen | July 30th 2008 at 1014 pm
6Renaud | July 30th 2008 at 1111 pm
Thank you for your kind words Irsquom glad you found some of these articles useful
Renaud
I have briefly looked over your custom message box concept and like what I see I am curioushowever because unless I am mistaken you have implemented it in Access using standard modulesrather than as a class Is there any particular reason you didnrsquot create a class instead
Glenn
7 Glenn | July 31st 2008 at 613 pm
Hi GlennI think the main reason I didnrsquot use a class was that I wanted a drop-in replacement for thestandard MsgBoxUsing a class would have required creating an instance of it either every time thebox would be used or stored somewhere in a moduleClasses also become an issue as they cannotbe instantiated directly from a library (the way I usually re-use code) and you must end-up having aclass factory in a Module instead
It doesnrsquot mean it canrsquot be done I just donrsquot think it bring anything useful doing it in a Class asopposed to a Module in this case
Maybe Irsquom wrong and there is a better way
In that case let me know -)
8Renaud | July 31st 2008 at 656 pm
Renaud
Thanks for that Your explanation makes perfect sense and I canrsquot think of a compelling reason tosuggest that a class based alternative would be preferable Code libraries are certainly the way to gofor frequently used code
While using a class in this case doesnrsquot appear to offer an advantage over your standard moduleapproach you might be interested to know that there are a couple of ways to include classes in codelibraries such that any application using the library can create instances of the relevant classes
Glenn
9 glenn | August 1st 2008 at 1226 am
This is rather awesome Mind if I take a shot at back-grading it to Access 97
10 Moo | August 1st 2008 at 649 am
GlennI use a simple module that I call ldquoClassFactoryrdquo whose only purpose is to return an instanceof the Classes in the library Not sure if there is a better way
Mooplease be my guest I have been thinking about this recently but since I only have Access2007 testing for older version is a bit of a challenge
Adapting the code to older versions should not be difficult if you stick to plain text You will have toremove references to the ldquoTextFormatrdquo property of the txtMessage textbox as it is new inAccess2007 and used to switch between plain text and rich text
As far as I know the only way to bring rich text to older versions of Access is to use a webbrowser
11Renaud | August 1st 2008 at 957 am
control
If you manage to convert it please send me the updated database so I can host it here for all to find
Renaud
You can do without the module by manipulating the class modulersquos Instancing property The catch isthat the property sheet doesnrsquot allow the setting you need but you can run a single statement in theimmediate window to do the job See this posthttpwwwutteraccesscomforumsshowthreadedphpCat=ampNumber=1441683amppage=ampview=ampsb=5ampo=ampvc=1
Glenn
12 Glenn | August 1st 2008 at 425 pm
Hi Glennthanks for the tip
13Renaud | August 3rd 2008 at 320 pm
Renaud
I gave it a shot and without the RTF it just wouldnrsquot be the same so I chose not to pursue it anyfurther
The Access 2007 version is striking Thanks
Moo
14 Moo | August 6th 2008 at 633 am
Get a compile error when trying to run it ldquoUser defined Type not definedrdquohelliphellipDim f As NewForm_FormDialogHave the same references checked in my Access 2007 VBA Looks great Wouldlike to solve the problem to be able to use it ThanksLarry
15 Larry | August 6th 2008 at 114 pm
This is excellent Irsquove just added it to a new application and it looks far better and I like the ability tocopy the message to the clipboard It is also very good that it is non-blocking ie I can now moreeasily chuck users out of my systems if I want say after a period of inactivityA point that peoplemight find useful is that rather than replace all instances of Msgbox in your code with the wordldquoRichBoxrdquo you can rename the new RichBox function as Msgbox When your code then goes to callthe Msgbox function it then calls the new function ie the old Msgbox gets overridden and the newfunction is called instead
16 Alan Cossey | August 7th 2008 at 402 am
Larry does this happen with the demo or in your applicationHave you renamed the FormDialogif thatrsquos the case make sure to change the line where you get the error to reflect the new nameAnother possibility is security settings if yoursquore getting a security warning when opening the filemake sure you open it from a Trusted location or some functions will be disabled
Alan itrsquos a good point and it could make replacement much easier although I usually prefer to erron the side of caution and avoid overriding base functionality to avoid unintended consequences (andkeep in line with the ldquoelement of least surpriserdquo motto by making things explicit) -)
17Renaud | August 7th 2008 at 207 pm
Thanks for the great object
Out of Stack Space Error
Occurs when modifying DefaultButtonDelayTry modifying the Enable Buttons In field in sample form
Problem occurs in module ldquoDialogrdquo
Reads
Should read
Public Property Let DefaultButtonDelay(delay As Long)
If delay lt 0 Then delay = 0
DefaultButtonDelay = delay
End Property
Public Property Let DefaultButtonDelay(delay As Long)
If delay lt 0 Then delay = 0
m_DefaultButtonDelay = delay
End Property
18 Geoffrey | August 8th 2008 at 1236 am
Compile error happens in my application which is in a Trusted location Didnrsquot rename anything otherthan MsgBox changed to Box as instructed for one of my boxes Am I supposed to renamesomething else The compile error highlights the following VBA codehelliphellipDim f As NewForm_FormDialogLarry
19 Larry | August 8th 2008 at 701 am
Geoffrey good catch I have updated the code Thanks for notifying me
Larry still not sure why yoursquore getting this Could you send me a zip file of your application so I caninvestigate Send it to accessblognkadesign (replacing by and by com)
20Renaud | August 8th 2008 at 1026 am
Larryyou were missing the FormDialog in your application
I have updated the article to list the instructions on how to include the new code into your ownapplication I realised this was missing
21Renaud | August 8th 2008 at 320 pm
Success Enhanced Message Boxes are so much easier to identify when they pop up on the screenThe standard msgboxes are so bland they are almost camoflauged Thank you very muchLarry
22 Larry | August 9th 2008 at 637 am
Your code is way better that what I have written and really works as a replacement to the standardMsgBox function
23Jack Stockton | August 9th 2008 at 656 am
Would like to suggest an enhancementhellipability to specify customer text for two I often have abusiness case where I am displaying a message box asking the user if they want to replace or openthe existing
I got stuckhellip
A friend sent me the A2003 version but it now appears that the RichTextocx is blocked because ofsecurity reasons (apparently they deem it safe in A2007) I registered RICHTX32ocx 60 (SP6) underreferences but the 2003 mdb doesnrsquot compile lsquoacTextFormatHTMLRichTextrsquo is not found -- I found aregistry-patch here httpp2pwroxcomtopicaspTOPIC_ID=10894 -- doesnrsquot work on my pc
There is also a replacement by Stephan Lebans httpwwwlebanscomrichtexthtm -- registeringit didnrsquot help either
Also the png images donrsquot load -- apparently they donrsquot get included on converting -- could youinclude them separately
Any suggestions I really would like to give this replacement a try -- I do see its potential but as Idonrsquot have A2007 I canrsquot run it as such
24Jacques | August 12th 2008 at 657 am
Jacques I can only think of the webbrowser control as a replacementMay be too much overhead but itrsquos worth a tryIrsquove sent you the icons by emailLet me know if yousucceed -)
25Renaud | August 12th 2008 at 351 pm
Thank you Pretty good work
Therersquos one extension Irsquod like to implement or see implemented autowrap for long texts
Therersquos one slight problem with the code as it standshellip The Default Buttons are not set properly TheCode for this looks fine until you notice that the buttons are named in the reverse order to their usebt3 is used as button1 etcetera The rest of the code reflects this the Timer event which sets thedefault does not Easy to change in the timer event just replace each occurence of bt1 with bt3 andbt3 with bt1
Thanks againAndycr
26Andrew Craven Rohm | August 12th 2008 at 610 pm
Whow What a great enhancement for my Access Tools I just tried it and was really happy
Now therersquos a variation I would love to see A modified InputBox Could you do that too
Regards from Germany
Stefan
27 Stefan Reichelt | August 13th 2008 at 1017 pm
Will this tool work with an adp file If so what mods are necessary
28 Joey | September 20th 2008 at 245 am
29Michael Merlin | September 28th 2008 at 627 am
Joey should work perfectly fine in adp
Renaud brilliant work
Thanks for this great enhancement I donrsquot seem to be able to get any of the buttons to be thedefault button any help would be greatly appreciated
Cheers from downunderScott
30 Scott Cordwell | October 30th 2008 at 1122 am
Scott glad you find it usefulRegarding the default button itrsquos not really a feature I wanted to use as one of the points of usingthis enhanced MessageBox is to force users to stop for a second and think about the action theyneed to perform rather than just hitting ENTER or ESC without thinking as is the case with thestandard box
Irsquoll make a note of your suggestion for the next update and probably add it as an option (or a defaultthat can be disabled)
31Renaud | October 30th 2008 at 348 pm
[] Change Color of Text Hi Akilah I ran across this that might help youhttpblognkadesigncom2008ms-achellipx-replacement Bonnie httpwwwdataplus-svccom Akilahwrote gtHi is there a way to change the color of []
32Change Color of Text | keamphellip | January 19th 2009 at 1244 am
Could someone send me an A2003 version of this code This sounds like exactly what I need
33 Dan | January 27th 2009 at 358 am
Hi Renaud -- this is awesome ) Just a quick question -- is there scope to include customising thebuttons So rather than the standard vbYes vbNo etc you can customise them
34 Andy | January 29th 2009 at 302 am
I downloaded your Enhanced MsgBox and it worked great It definitely fit the bill for what I was doinguntil I created an ACCDE version for the users I end up with the error The expression you enteredhas a function name that the database canrsquot find
I have the Enhanced MsgBox getting called during an ldquoon clickrdquo event on a button by using=RichBox([field])
Any ideas
35 Ryan | February 6th 2009 at 910 am
I fixed your vbDefaultButton behavior bug in Form_Timer() can I send you the code
36Henry | February 7th 2009 at 248 am
To Ryan have you tried calling the RichBox from code rather than directly from the Onclick event
37Renaud | February 7th 2009 at 923 am
handler
To Henry yes please send the fix and I will update the code and the samples for everyone My emailis in the footer of the pageThank you
Itrsquos been a long time since Irsquove used Access and so Irsquom getting my feet re-wet Can you refresh me onsome code I would use to call it
38 Ryan | February 7th 2009 at 832 pm
Thanks for this excelent code I think it may be usful to a project I may play with later on
39Andrew | February 18th 2009 at 122 am
Great work based on details and comments I canrsquot possibly use this utility in Access 2002 can I
40 Ash | February 23rd 2009 at 1142 am
Ash thanks Unfortunately there is a major show-stopper if you want to get this to work in pre-2007 versions of Access
older versions donrsquot have rich-edit textboxes so you would probably have to rely on a webbrowsercomponent and that would change a lot
If you are OK with being limited to the plain version of the enhanced MsgBox then your only otherissue should be with displaying transparent images for the icons
41Renaud | February 23rd 2009 at 1238 pm
Have you developed the code for those of us non-Office 2007 users I have Office 2003 and wouldreally like to apply this enhancement
ThanksTom
42 Tom Dessert | March 6th 2009 at 428 am
Tom Dessert no I thought some good soul would try Irsquod be happy if someone did
My main issue is that I donrsquot have any older version of Access so I canrsquot really test theimplementation and be sure about the result Just saving the project in an older format wonrsquot workproperly at Irsquom using some A2007-specific features
43Renaud | March 9th 2009 at 1008 am
Brilliant code Renaudhellip Very helpfulhellip Thanks Irsquom old at Access but new to the type of coding youused to create the enhanced msgbox I am hoping to use your code to allow users to activate customhelp files from a Help button in some dialogs (doesnrsquot seem to work in standard Access 2007 msgbox-- just fires up the Access help even when custom help file and context are indicated)In my firstattepts to use your box I see that I can now reach the forms help file using F1 from the dialogboxbut it must be possible to use the standard Help buttonCan you help or advise pleaseRegards John
44 John White | May 13th 2009 at 323 pm
45 John White | May 13th 2009 at 715 pm
Regarding my last commenthellip Irsquove added a button in the same way as your btCopy and BtSave andput Sendkeys ldquoF1rdquo into the Click event to fire my custom help
Next issue please I like to set the mouse pointer to jump to default buttons on dialog boxes whichworks with the standard Access 2007 dialogs but not with my new good looking ones Is it possibleto obtain this behaviour on the custom dialog boxRegards John
Thanks for this excelent code fantastic hellip )
46 Uros | June 29th 2009 at 433 pm
Thank you for your hard work and the wonderful message box A quick comment I will be using thisbox to display a warning to my users that I will be terminating their connection so I can performupdates to the back end Irsquod like the Box to AutoClose after a certain period of time regardless ofuser interaction (or more likely non-interaction) I can program this in myself but it may be a usefulfeature to others as well
Thanks againMatthew Pfluger
47 Matthew Pfluger | July 23rd 2009 at 1213 am
Thanks for the great code I added a line to default the dialog caption to the application name if notitle is explicitly set
First few lines of Form_FormDialogShowModal are If m_Title ltgt ldquordquo Then caption = m_Title amp rdquo rdquo Elsecaption = CurrentDbProperties(ldquoAppTitlerdquo) End If
48 kirkrqm | August 8th 2009 at 837 pm
Hi
Tnx 4 your beautiful messagebox I only have one question is it possible to use a vbTab in themessage
With regardsMarianne
49 Marianne Berkhof | October 8th 2009 at 801 pm
Do you have an inputbox variant for this as well
If only i had the time to combine this withhttpwwwdatabasejournalcomfeaturesmsaccessarticlephp3848121Extending-the-InputBox-function-for-MS-Access-Formshtm
Spare time Anybody
50 Lxocram | December 18th 2009 at 457 pm
Sir this is most excellent Thanks for sharing
51 David | February 13th 2010 at 953 pm
I have downloaded your example database Irsquom using Access 2007 but something odd happens Nonof the buttons on the test form seems to activate a trigger In short nothing happens Do you havean explaination for that
52 John | February 16th 2010 at 429 pm
I would like to use vba code to close a message boc programmatically as Matthew Pfluger suggesthe can do in his July 23rd 2009 message Can someone please tell me how to do this
I too am an avid user of your message box replacement
Thanks Bob Robinson
53Bob Robinson | April 16th 2010 at 857 pm
This looks very useful could you please post the source code so those of us not using 2007 can havea go at extracting those parts that will work in earlier versions
Many Thanks
Dave
54 Dave | May 25th 2010 at 1008 pm
[] found the custom message boxes at httpblognkadesigncom2008ms-achellipx-replacement andedited it to fit my needs mdash Background colours borders etc as well as the Images []
55Deleted Image displayed wamphellip | June 17th 2010 at 702 pm
Do you know of any similar utility for MS Excel
Ken
56 Ken Warthen | October 27th 2010 at 215 am
[] really but you can create your own httpblognkadesigncom2008ms-achellip-replacement__________________ (RG for short) aka Allan Bunch MS Access MVP -- WinXP Pro Win7 Pro- acXP[]
57MsgBox Placementamphellip | December 27th 2010 at 345 am
A nice replacement message box that solves the problem (found under Access 2010) of dialog boxesstopping being lsquomodalrsquo before the user presses a button
However the png graphics image files would really be appreciatedhellip
My app has to be capable of running under Access 2003 2007 and 2010 so to keep a similar look andfeel I need to create some bitmaps for the old version
58 Sooz | January 25th 2011 at 242 am
Superb Just came across this it has given my application a ldquofinishedrdquo look One question how do Iforce the application to close after the DialogRichBox appears I checked the example and the checkbox does not fire any code
59 Greg | February 5th 2011 at 417 am
RichText version of the enhanced custom message box under the Office Black Colour Scheme
Here are the features of the enhanced message box
It is entirely compatible with the standard one just change MsgBox to Box using find and replace
should be enough (see tip below to avoid getting strange errors)It allows the user to simply click on a button to copy the content of the message to the clipboard orsave it to a text file to a configurable default locationIt looks and feels like it belongs to the main application following its colour schemeIt attempts to prevent users from blindly closing the modal box reading the message buttons will firstbe inactive for a configurable amount of time Itrsquos not a perfect solution but it is quite effectiveThere is a RichBox version that can display rich HTML content not just plain text so important parts
of the message can be formatted in a useful wayIt is able to display large amount of data While itrsquos not something you usually want it may be usefulfor the message box to display more text in some situations (log or tracing information legaldocumentation etc)Rather than sprinkling your code with ldquo amp vbCrLf amp _ rdquo uglies you can embed newlines in the text itself
by using C-style ldquo n rdquo escape sequences that will automatically be transformed into the appropriate
newlines Makes for clearer code and less typingBecause you get the source you can easily customise the message box with new icons and colours tobetter match your overall applicationrsquos personalityIt is non-blocking if your application forces users to log-off after a certain amount of inactivity theenhanced message box will just close rather than prevent Access from shutting down like thestandard MsgBox does Of course itrsquos up to you to decide how to handle that gracefully if at all
It properly displays the expected button captions based on the language of the operating system so itbehaves very much like the default MsgBox (for instance it will properly display ldquoCancelrdquo on English
systems and ldquoAnnulerrdquo on French ones)It also properly plays the system sounds associated with the type of message You can also enable ordisable the sound effect as needed
How to use it
Download the demo below and copy (drag amp drop) the following into your application
the FormDialog form
the API_GetTextMetrics module
the Dialog module
If you rename the FormDialog make sure you replace any occurrence to it in the code in particular in the
Dialog module
Since the enhanced message box is just a replacement for the standard one you just use it like youwould use the MsgBox
There are a few additional settings that can be used to change the behaviour of the enhanced messageboxesOne is that you can adjust the delay before the buttons become activated
Another one is that you can enable or disable whether beeps should be played or not
The last settings is the folder where we should save the content of the message when the user clicks theSave button on the message box
view plain copy to clipboard print
----------------------------------------------------------------------------- Simple use of the Plaintext box Note the use of n that will be converted into a newlineDialogBox This is a plaintext messagenClick OK to dismissvbOKOnly+vbinformation _Message Title----------------------------------------------------------------------------- Getting the result backDim dr as vbMsgBoxresultdr = DialogBox(Are you sure you want to delete _vbYesNoCancel+vbQuestion Confirm action)if (dr = vbYes) then DeleteRecords----------------------------------------------------------------------------- Using named parametersDialogBox Prompt=All your bases are belong to us _Buttons=(vbOkOnly+vbCritical) _Title=Bad error----------------------------------------------------------------------------- Using the RichBox to display simple HTML The first line will be bold then the word button will be printed in red Here the n will be escaped to ltbrgt tags to simulate newlinesDialogRichBox ltstronggtThis is a bold messageltstronggtn amp _Click the ltfont color=FF0000gtbuttonltfontgt to dismissvbOKOnly+vbinformation _RichText Message Title
view plain copy to clipboard print
----------------------------------------------------------------------------- Use the ButtonDelay to specify the time in seconds before the buttons become activated The default is 2s Use 0 to activate the buttons immediatelyDialogBox Prompt=All your bases are belong to us _Buttons=(vbOkOnly+vbCritical) _Title=Bad errorButtonDelay=1----------------------------------------------------------------------------- Change the default delay value To disable the activation delayDialogDefaultButtonDelay = 0 To make the user wait 3 seconds before they can press any buttonDialogDefaultButtonDelay = 3
view plain copy to clipboard print
----------------------------------------------------------------------------- Use AllowBeep to specify whether beeps should be played when the message box opens By default they areDialogBox Prompt=All your bases are belong to us _Buttons=(vbOkOnly+vbCritical) _Title=Bad errorAllowBeep=false----------------------------------------------------------------------------- Change the default behaviour This is true by defaultDialogDefaultAllowBeep = false
view plain copy to clipboard print
----------------------------------------------------------------------------- Change the save folder By default the text messages will be saved in the same directory as the database Here we want them to be saved to a temp directory
These few settings make the enhanced message box more customizable
Large text
The standard MsgBox cannot display much text On the other hand there is no real limitation to the
amount of text the Box and RichBox can display
When the amount of information is too much to fit the maximum allowed size for the message box thetext will overflow and can be scrolled updown as necessary
Limitations of the RichBox
The RichBox version relies on the normal TextBox controlrsquos ability under Access 2007 to display RichText
wich is nothing more than lightweight HTMLBecause font size may be varying a lot in the message it becomes very difficult to accurately predict thesize of the box needed to display the whole messageShort of implementing a complete HTML engine we have to rely on some assumptions to display HTMLThe risk is that sometimes the content may not properly fit the TextBox control in some circumstancesIf you use the RichBox thoroughly try displaying your messages and tweak the HTML as necessary to
include additional lines or non-breaking spaces to ensure that the result looks goodIf you donrsquot overuse font size and donrsquot display in multiple fonts the RichBox should do the right thing
most of the timeDonrsquot overuse the RichBox to display colourful messages There is a fine line between being informative
and tasteless Keep colours and formatting where it is usefulI think that in most cases the plain text version Box is more than enough
Replacing MsgBox in existing code
As I said above replacing the standard MsgBox is easy but you need to make sure your search and
replace parameters are configured correctly
If yoursquore getting strange compile errors it may be because you forgot to tick the Find Whole Word Onlyand some of the strings containing the letter sequence ldquomsgboxrdquo were replaced in the process
If thatrsquos the case you can revert the damage by simply doing a search and replace across the wholeproject on- VbboxStyle or VbDialogBoxStyle to be replaced with VbMsgBoxStyle
- VbboxResult or VbDialogBoxResult to be replaced with VbMsgBoxResult
How it works
The code makes extensive use of Win32 API callsMost of the hard work is done in the FomDialog class form There is too much there to really go into the
details but you are welcome to have a look at the commented code
DialogDefaultSavedTextFileFolder= Ctemp
The code relies also on a utility function from Stephen Lebans used to calculate the size of of text I havemade some minor modification to that code so I would refer you to his original implementation if you areinterested in calculating TextBox sizes for forms or reports
In the code for the FormDialog I re-implement some of the expected functionalities of the MsgBox
proper arrangement of the buttons displaying of the appropriate icon etcOnce this is done we calculate the size of the textbox needed to display the whole of the messageIn the case of RichText we first use ApplicationPlainText() to convert the HTML into properly
formatted plain text We then calculate the Textbox size using a slightly larger font than needed as a wayto ensure that the content of the RichText message will fit the box in most casesOnce we know the size of the TextBox we can easily resize the form to properly display the TextBoxIf there is too much text we resize the form to its maximum permissible (70 or screen width and 90of screen height) and change some of the visual cues to let the user know the text is overflowing
One thing of note is the way the form is kept modalRather than using DoCmdOpenForm and DoCmdClose I use the form as a class and create an instance
manually (see the code in DialogBox and DialogRichbox ) I keep this instance alive until I got the formrsquos
result backIf you are interested in knowing how the form is made modal this is the code in FormDialogShowModal()
what keeps the form open until the user clicks a button
The Sleep() function is a Win32 API that stops the current process for the given number of milliseconds
This in effects hands back the control to the Operating System for a short time That way the system isstill responsive and does not consume resources when itrsquos just waiting for user input
Sample database
You can download a sample database containing all the necessary code as well as a number of testsThis version only contains the database in Microsoft Access 2007 accdb format
view plain copy to clipboard print
01 Public Function ShowModal() As VbMsgBoxResult02 03 Here we reset the result for the clicked button such as vbOK vbYes etc04 This is set in each Buttons Click event05 m_Result = -106 Wait for the user to click a button07 Do While (m_Result = -1)08 DoEvents09 Sleep 5010 Loop11 ShowModal = m_Result12 End Function
Download the EnhancedMsgBox01zip (116KB) v13 containing the ACCDB database
Code Updates
v13 17MAR2009Thanks to Henry of Access-Prode for proposing a correction to the default buttons behaviour
Updated behaviour for the default buttons They are now focused in a way that matches that of thestandard msgboxReversed the naming of the buttons on the form to make it a bit more consistent with the standardbox
v12 07SEP2008Thanks to Andy Colonna (httpwwwpcesoftcom) for uncovering the following bugs (check out his freeSpell Checker with source code)
Corrected bug in Form_FormDialogFilenameSanitize() function that would fail to remove all invalid
characters for a file nameFile name for the saved text message will be truncated to first 32 characters of message box title inForm_FormDialogMakeFriendlyFileName()
Changed the use of FollowHyperlink to ShellExecute to avoid security warningin some instances inForm_FormDialogbtCopyToFile_Click()
Corrected twips to pixel conversion bug in API_GetTextMetricsfTextWidthOrHeight() that would result
in an improperly sized dialog box when the text message was too wide
v11 08AUG2008
Corrected code for DefaultButtonDelay (thanks to Geoffrey) (was referencingwrong variable causing
self-referencing code)Corrected code for Box and RichBox to take the DefaultSavedTextFileFolder into account (the path
was previously not passed onto the dialog boxes and the text file would always be created in theapplication folder instead of the one specified by DefaultSavedTextFileFolder )
Added license notice at top of source code
v10 20MAY2008
Original version
Resources
Dissecting the MessageBox article on CodeProjectXMessageBox -- A reverse-engineered MessageBox() article on CodeProjectTextWidth-Height code demo from Stephen Lebans (great resource check it out)Pixel to Twips conversion from MSDNCopy Text to Clipboard from the excellent site The Access WebGetting Resource Strings and more from DLLs
This work is licensed under a Creative Commons Attribution 30 Unported LicenseFree for re-use in any application or tutorial providing clear credit is made about the origin of the codeand a link to this site is prominently displayed where end-users can easily access it
Entry Filed under NetBusinessDatabaseMSAccessProgramming
59 Comments Add your own
WAO
i cannot say more this is extremely good
i saw other solutions but yours surpass all others congratulations
keep on doing the good work
1Edwin Blancovitch | June 5th 2008 at 500 am
Thank you EdwinThere are plenty more that Irsquod like to do just a matter of finding the timehellip
2Renaud | June 7th 2008 at 404 pm
Simply smart Thank you Sir
3 Marvin | June 30th 2008 at 200 pm
Simply fantastic great work thank you
4 Anon | June 30th 2008 at 1159 pm
Renaud
Your website was a real find I love the enhanced message box utility for Access as well as the modaldialogs with transparent backgrounds These are awesome tools that help Access developers tocreate interfaces that have some visual appeal Thanks so much for your efforts and generosity
Ken Warthen
5 Ken Warthen | July 30th 2008 at 1014 pm
6Renaud | July 30th 2008 at 1111 pm
Thank you for your kind words Irsquom glad you found some of these articles useful
Renaud
I have briefly looked over your custom message box concept and like what I see I am curioushowever because unless I am mistaken you have implemented it in Access using standard modulesrather than as a class Is there any particular reason you didnrsquot create a class instead
Glenn
7 Glenn | July 31st 2008 at 613 pm
Hi GlennI think the main reason I didnrsquot use a class was that I wanted a drop-in replacement for thestandard MsgBoxUsing a class would have required creating an instance of it either every time thebox would be used or stored somewhere in a moduleClasses also become an issue as they cannotbe instantiated directly from a library (the way I usually re-use code) and you must end-up having aclass factory in a Module instead
It doesnrsquot mean it canrsquot be done I just donrsquot think it bring anything useful doing it in a Class asopposed to a Module in this case
Maybe Irsquom wrong and there is a better way
In that case let me know -)
8Renaud | July 31st 2008 at 656 pm
Renaud
Thanks for that Your explanation makes perfect sense and I canrsquot think of a compelling reason tosuggest that a class based alternative would be preferable Code libraries are certainly the way to gofor frequently used code
While using a class in this case doesnrsquot appear to offer an advantage over your standard moduleapproach you might be interested to know that there are a couple of ways to include classes in codelibraries such that any application using the library can create instances of the relevant classes
Glenn
9 glenn | August 1st 2008 at 1226 am
This is rather awesome Mind if I take a shot at back-grading it to Access 97
10 Moo | August 1st 2008 at 649 am
GlennI use a simple module that I call ldquoClassFactoryrdquo whose only purpose is to return an instanceof the Classes in the library Not sure if there is a better way
Mooplease be my guest I have been thinking about this recently but since I only have Access2007 testing for older version is a bit of a challenge
Adapting the code to older versions should not be difficult if you stick to plain text You will have toremove references to the ldquoTextFormatrdquo property of the txtMessage textbox as it is new inAccess2007 and used to switch between plain text and rich text
As far as I know the only way to bring rich text to older versions of Access is to use a webbrowser
11Renaud | August 1st 2008 at 957 am
control
If you manage to convert it please send me the updated database so I can host it here for all to find
Renaud
You can do without the module by manipulating the class modulersquos Instancing property The catch isthat the property sheet doesnrsquot allow the setting you need but you can run a single statement in theimmediate window to do the job See this posthttpwwwutteraccesscomforumsshowthreadedphpCat=ampNumber=1441683amppage=ampview=ampsb=5ampo=ampvc=1
Glenn
12 Glenn | August 1st 2008 at 425 pm
Hi Glennthanks for the tip
13Renaud | August 3rd 2008 at 320 pm
Renaud
I gave it a shot and without the RTF it just wouldnrsquot be the same so I chose not to pursue it anyfurther
The Access 2007 version is striking Thanks
Moo
14 Moo | August 6th 2008 at 633 am
Get a compile error when trying to run it ldquoUser defined Type not definedrdquohelliphellipDim f As NewForm_FormDialogHave the same references checked in my Access 2007 VBA Looks great Wouldlike to solve the problem to be able to use it ThanksLarry
15 Larry | August 6th 2008 at 114 pm
This is excellent Irsquove just added it to a new application and it looks far better and I like the ability tocopy the message to the clipboard It is also very good that it is non-blocking ie I can now moreeasily chuck users out of my systems if I want say after a period of inactivityA point that peoplemight find useful is that rather than replace all instances of Msgbox in your code with the wordldquoRichBoxrdquo you can rename the new RichBox function as Msgbox When your code then goes to callthe Msgbox function it then calls the new function ie the old Msgbox gets overridden and the newfunction is called instead
16 Alan Cossey | August 7th 2008 at 402 am
Larry does this happen with the demo or in your applicationHave you renamed the FormDialogif thatrsquos the case make sure to change the line where you get the error to reflect the new nameAnother possibility is security settings if yoursquore getting a security warning when opening the filemake sure you open it from a Trusted location or some functions will be disabled
Alan itrsquos a good point and it could make replacement much easier although I usually prefer to erron the side of caution and avoid overriding base functionality to avoid unintended consequences (andkeep in line with the ldquoelement of least surpriserdquo motto by making things explicit) -)
17Renaud | August 7th 2008 at 207 pm
Thanks for the great object
Out of Stack Space Error
Occurs when modifying DefaultButtonDelayTry modifying the Enable Buttons In field in sample form
Problem occurs in module ldquoDialogrdquo
Reads
Should read
Public Property Let DefaultButtonDelay(delay As Long)
If delay lt 0 Then delay = 0
DefaultButtonDelay = delay
End Property
Public Property Let DefaultButtonDelay(delay As Long)
If delay lt 0 Then delay = 0
m_DefaultButtonDelay = delay
End Property
18 Geoffrey | August 8th 2008 at 1236 am
Compile error happens in my application which is in a Trusted location Didnrsquot rename anything otherthan MsgBox changed to Box as instructed for one of my boxes Am I supposed to renamesomething else The compile error highlights the following VBA codehelliphellipDim f As NewForm_FormDialogLarry
19 Larry | August 8th 2008 at 701 am
Geoffrey good catch I have updated the code Thanks for notifying me
Larry still not sure why yoursquore getting this Could you send me a zip file of your application so I caninvestigate Send it to accessblognkadesign (replacing by and by com)
20Renaud | August 8th 2008 at 1026 am
Larryyou were missing the FormDialog in your application
I have updated the article to list the instructions on how to include the new code into your ownapplication I realised this was missing
21Renaud | August 8th 2008 at 320 pm
Success Enhanced Message Boxes are so much easier to identify when they pop up on the screenThe standard msgboxes are so bland they are almost camoflauged Thank you very muchLarry
22 Larry | August 9th 2008 at 637 am
Your code is way better that what I have written and really works as a replacement to the standardMsgBox function
23Jack Stockton | August 9th 2008 at 656 am
Would like to suggest an enhancementhellipability to specify customer text for two I often have abusiness case where I am displaying a message box asking the user if they want to replace or openthe existing
I got stuckhellip
A friend sent me the A2003 version but it now appears that the RichTextocx is blocked because ofsecurity reasons (apparently they deem it safe in A2007) I registered RICHTX32ocx 60 (SP6) underreferences but the 2003 mdb doesnrsquot compile lsquoacTextFormatHTMLRichTextrsquo is not found -- I found aregistry-patch here httpp2pwroxcomtopicaspTOPIC_ID=10894 -- doesnrsquot work on my pc
There is also a replacement by Stephan Lebans httpwwwlebanscomrichtexthtm -- registeringit didnrsquot help either
Also the png images donrsquot load -- apparently they donrsquot get included on converting -- could youinclude them separately
Any suggestions I really would like to give this replacement a try -- I do see its potential but as Idonrsquot have A2007 I canrsquot run it as such
24Jacques | August 12th 2008 at 657 am
Jacques I can only think of the webbrowser control as a replacementMay be too much overhead but itrsquos worth a tryIrsquove sent you the icons by emailLet me know if yousucceed -)
25Renaud | August 12th 2008 at 351 pm
Thank you Pretty good work
Therersquos one extension Irsquod like to implement or see implemented autowrap for long texts
Therersquos one slight problem with the code as it standshellip The Default Buttons are not set properly TheCode for this looks fine until you notice that the buttons are named in the reverse order to their usebt3 is used as button1 etcetera The rest of the code reflects this the Timer event which sets thedefault does not Easy to change in the timer event just replace each occurence of bt1 with bt3 andbt3 with bt1
Thanks againAndycr
26Andrew Craven Rohm | August 12th 2008 at 610 pm
Whow What a great enhancement for my Access Tools I just tried it and was really happy
Now therersquos a variation I would love to see A modified InputBox Could you do that too
Regards from Germany
Stefan
27 Stefan Reichelt | August 13th 2008 at 1017 pm
Will this tool work with an adp file If so what mods are necessary
28 Joey | September 20th 2008 at 245 am
29Michael Merlin | September 28th 2008 at 627 am
Joey should work perfectly fine in adp
Renaud brilliant work
Thanks for this great enhancement I donrsquot seem to be able to get any of the buttons to be thedefault button any help would be greatly appreciated
Cheers from downunderScott
30 Scott Cordwell | October 30th 2008 at 1122 am
Scott glad you find it usefulRegarding the default button itrsquos not really a feature I wanted to use as one of the points of usingthis enhanced MessageBox is to force users to stop for a second and think about the action theyneed to perform rather than just hitting ENTER or ESC without thinking as is the case with thestandard box
Irsquoll make a note of your suggestion for the next update and probably add it as an option (or a defaultthat can be disabled)
31Renaud | October 30th 2008 at 348 pm
[] Change Color of Text Hi Akilah I ran across this that might help youhttpblognkadesigncom2008ms-achellipx-replacement Bonnie httpwwwdataplus-svccom Akilahwrote gtHi is there a way to change the color of []
32Change Color of Text | keamphellip | January 19th 2009 at 1244 am
Could someone send me an A2003 version of this code This sounds like exactly what I need
33 Dan | January 27th 2009 at 358 am
Hi Renaud -- this is awesome ) Just a quick question -- is there scope to include customising thebuttons So rather than the standard vbYes vbNo etc you can customise them
34 Andy | January 29th 2009 at 302 am
I downloaded your Enhanced MsgBox and it worked great It definitely fit the bill for what I was doinguntil I created an ACCDE version for the users I end up with the error The expression you enteredhas a function name that the database canrsquot find
I have the Enhanced MsgBox getting called during an ldquoon clickrdquo event on a button by using=RichBox([field])
Any ideas
35 Ryan | February 6th 2009 at 910 am
I fixed your vbDefaultButton behavior bug in Form_Timer() can I send you the code
36Henry | February 7th 2009 at 248 am
To Ryan have you tried calling the RichBox from code rather than directly from the Onclick event
37Renaud | February 7th 2009 at 923 am
handler
To Henry yes please send the fix and I will update the code and the samples for everyone My emailis in the footer of the pageThank you
Itrsquos been a long time since Irsquove used Access and so Irsquom getting my feet re-wet Can you refresh me onsome code I would use to call it
38 Ryan | February 7th 2009 at 832 pm
Thanks for this excelent code I think it may be usful to a project I may play with later on
39Andrew | February 18th 2009 at 122 am
Great work based on details and comments I canrsquot possibly use this utility in Access 2002 can I
40 Ash | February 23rd 2009 at 1142 am
Ash thanks Unfortunately there is a major show-stopper if you want to get this to work in pre-2007 versions of Access
older versions donrsquot have rich-edit textboxes so you would probably have to rely on a webbrowsercomponent and that would change a lot
If you are OK with being limited to the plain version of the enhanced MsgBox then your only otherissue should be with displaying transparent images for the icons
41Renaud | February 23rd 2009 at 1238 pm
Have you developed the code for those of us non-Office 2007 users I have Office 2003 and wouldreally like to apply this enhancement
ThanksTom
42 Tom Dessert | March 6th 2009 at 428 am
Tom Dessert no I thought some good soul would try Irsquod be happy if someone did
My main issue is that I donrsquot have any older version of Access so I canrsquot really test theimplementation and be sure about the result Just saving the project in an older format wonrsquot workproperly at Irsquom using some A2007-specific features
43Renaud | March 9th 2009 at 1008 am
Brilliant code Renaudhellip Very helpfulhellip Thanks Irsquom old at Access but new to the type of coding youused to create the enhanced msgbox I am hoping to use your code to allow users to activate customhelp files from a Help button in some dialogs (doesnrsquot seem to work in standard Access 2007 msgbox-- just fires up the Access help even when custom help file and context are indicated)In my firstattepts to use your box I see that I can now reach the forms help file using F1 from the dialogboxbut it must be possible to use the standard Help buttonCan you help or advise pleaseRegards John
44 John White | May 13th 2009 at 323 pm
45 John White | May 13th 2009 at 715 pm
Regarding my last commenthellip Irsquove added a button in the same way as your btCopy and BtSave andput Sendkeys ldquoF1rdquo into the Click event to fire my custom help
Next issue please I like to set the mouse pointer to jump to default buttons on dialog boxes whichworks with the standard Access 2007 dialogs but not with my new good looking ones Is it possibleto obtain this behaviour on the custom dialog boxRegards John
Thanks for this excelent code fantastic hellip )
46 Uros | June 29th 2009 at 433 pm
Thank you for your hard work and the wonderful message box A quick comment I will be using thisbox to display a warning to my users that I will be terminating their connection so I can performupdates to the back end Irsquod like the Box to AutoClose after a certain period of time regardless ofuser interaction (or more likely non-interaction) I can program this in myself but it may be a usefulfeature to others as well
Thanks againMatthew Pfluger
47 Matthew Pfluger | July 23rd 2009 at 1213 am
Thanks for the great code I added a line to default the dialog caption to the application name if notitle is explicitly set
First few lines of Form_FormDialogShowModal are If m_Title ltgt ldquordquo Then caption = m_Title amp rdquo rdquo Elsecaption = CurrentDbProperties(ldquoAppTitlerdquo) End If
48 kirkrqm | August 8th 2009 at 837 pm
Hi
Tnx 4 your beautiful messagebox I only have one question is it possible to use a vbTab in themessage
With regardsMarianne
49 Marianne Berkhof | October 8th 2009 at 801 pm
Do you have an inputbox variant for this as well
If only i had the time to combine this withhttpwwwdatabasejournalcomfeaturesmsaccessarticlephp3848121Extending-the-InputBox-function-for-MS-Access-Formshtm
Spare time Anybody
50 Lxocram | December 18th 2009 at 457 pm
Sir this is most excellent Thanks for sharing
51 David | February 13th 2010 at 953 pm
I have downloaded your example database Irsquom using Access 2007 but something odd happens Nonof the buttons on the test form seems to activate a trigger In short nothing happens Do you havean explaination for that
52 John | February 16th 2010 at 429 pm
I would like to use vba code to close a message boc programmatically as Matthew Pfluger suggesthe can do in his July 23rd 2009 message Can someone please tell me how to do this
I too am an avid user of your message box replacement
Thanks Bob Robinson
53Bob Robinson | April 16th 2010 at 857 pm
This looks very useful could you please post the source code so those of us not using 2007 can havea go at extracting those parts that will work in earlier versions
Many Thanks
Dave
54 Dave | May 25th 2010 at 1008 pm
[] found the custom message boxes at httpblognkadesigncom2008ms-achellipx-replacement andedited it to fit my needs mdash Background colours borders etc as well as the Images []
55Deleted Image displayed wamphellip | June 17th 2010 at 702 pm
Do you know of any similar utility for MS Excel
Ken
56 Ken Warthen | October 27th 2010 at 215 am
[] really but you can create your own httpblognkadesigncom2008ms-achellip-replacement__________________ (RG for short) aka Allan Bunch MS Access MVP -- WinXP Pro Win7 Pro- acXP[]
57MsgBox Placementamphellip | December 27th 2010 at 345 am
A nice replacement message box that solves the problem (found under Access 2010) of dialog boxesstopping being lsquomodalrsquo before the user presses a button
However the png graphics image files would really be appreciatedhellip
My app has to be capable of running under Access 2003 2007 and 2010 so to keep a similar look andfeel I need to create some bitmaps for the old version
58 Sooz | January 25th 2011 at 242 am
Superb Just came across this it has given my application a ldquofinishedrdquo look One question how do Iforce the application to close after the DialogRichBox appears I checked the example and the checkbox does not fire any code
59 Greg | February 5th 2011 at 417 am
There are a few additional settings that can be used to change the behaviour of the enhanced messageboxesOne is that you can adjust the delay before the buttons become activated
Another one is that you can enable or disable whether beeps should be played or not
The last settings is the folder where we should save the content of the message when the user clicks theSave button on the message box
view plain copy to clipboard print
----------------------------------------------------------------------------- Simple use of the Plaintext box Note the use of n that will be converted into a newlineDialogBox This is a plaintext messagenClick OK to dismissvbOKOnly+vbinformation _Message Title----------------------------------------------------------------------------- Getting the result backDim dr as vbMsgBoxresultdr = DialogBox(Are you sure you want to delete _vbYesNoCancel+vbQuestion Confirm action)if (dr = vbYes) then DeleteRecords----------------------------------------------------------------------------- Using named parametersDialogBox Prompt=All your bases are belong to us _Buttons=(vbOkOnly+vbCritical) _Title=Bad error----------------------------------------------------------------------------- Using the RichBox to display simple HTML The first line will be bold then the word button will be printed in red Here the n will be escaped to ltbrgt tags to simulate newlinesDialogRichBox ltstronggtThis is a bold messageltstronggtn amp _Click the ltfont color=FF0000gtbuttonltfontgt to dismissvbOKOnly+vbinformation _RichText Message Title
view plain copy to clipboard print
----------------------------------------------------------------------------- Use the ButtonDelay to specify the time in seconds before the buttons become activated The default is 2s Use 0 to activate the buttons immediatelyDialogBox Prompt=All your bases are belong to us _Buttons=(vbOkOnly+vbCritical) _Title=Bad errorButtonDelay=1----------------------------------------------------------------------------- Change the default delay value To disable the activation delayDialogDefaultButtonDelay = 0 To make the user wait 3 seconds before they can press any buttonDialogDefaultButtonDelay = 3
view plain copy to clipboard print
----------------------------------------------------------------------------- Use AllowBeep to specify whether beeps should be played when the message box opens By default they areDialogBox Prompt=All your bases are belong to us _Buttons=(vbOkOnly+vbCritical) _Title=Bad errorAllowBeep=false----------------------------------------------------------------------------- Change the default behaviour This is true by defaultDialogDefaultAllowBeep = false
view plain copy to clipboard print
----------------------------------------------------------------------------- Change the save folder By default the text messages will be saved in the same directory as the database Here we want them to be saved to a temp directory
These few settings make the enhanced message box more customizable
Large text
The standard MsgBox cannot display much text On the other hand there is no real limitation to the
amount of text the Box and RichBox can display
When the amount of information is too much to fit the maximum allowed size for the message box thetext will overflow and can be scrolled updown as necessary
Limitations of the RichBox
The RichBox version relies on the normal TextBox controlrsquos ability under Access 2007 to display RichText
wich is nothing more than lightweight HTMLBecause font size may be varying a lot in the message it becomes very difficult to accurately predict thesize of the box needed to display the whole messageShort of implementing a complete HTML engine we have to rely on some assumptions to display HTMLThe risk is that sometimes the content may not properly fit the TextBox control in some circumstancesIf you use the RichBox thoroughly try displaying your messages and tweak the HTML as necessary to
include additional lines or non-breaking spaces to ensure that the result looks goodIf you donrsquot overuse font size and donrsquot display in multiple fonts the RichBox should do the right thing
most of the timeDonrsquot overuse the RichBox to display colourful messages There is a fine line between being informative
and tasteless Keep colours and formatting where it is usefulI think that in most cases the plain text version Box is more than enough
Replacing MsgBox in existing code
As I said above replacing the standard MsgBox is easy but you need to make sure your search and
replace parameters are configured correctly
If yoursquore getting strange compile errors it may be because you forgot to tick the Find Whole Word Onlyand some of the strings containing the letter sequence ldquomsgboxrdquo were replaced in the process
If thatrsquos the case you can revert the damage by simply doing a search and replace across the wholeproject on- VbboxStyle or VbDialogBoxStyle to be replaced with VbMsgBoxStyle
- VbboxResult or VbDialogBoxResult to be replaced with VbMsgBoxResult
How it works
The code makes extensive use of Win32 API callsMost of the hard work is done in the FomDialog class form There is too much there to really go into the
details but you are welcome to have a look at the commented code
DialogDefaultSavedTextFileFolder= Ctemp
The code relies also on a utility function from Stephen Lebans used to calculate the size of of text I havemade some minor modification to that code so I would refer you to his original implementation if you areinterested in calculating TextBox sizes for forms or reports
In the code for the FormDialog I re-implement some of the expected functionalities of the MsgBox
proper arrangement of the buttons displaying of the appropriate icon etcOnce this is done we calculate the size of the textbox needed to display the whole of the messageIn the case of RichText we first use ApplicationPlainText() to convert the HTML into properly
formatted plain text We then calculate the Textbox size using a slightly larger font than needed as a wayto ensure that the content of the RichText message will fit the box in most casesOnce we know the size of the TextBox we can easily resize the form to properly display the TextBoxIf there is too much text we resize the form to its maximum permissible (70 or screen width and 90of screen height) and change some of the visual cues to let the user know the text is overflowing
One thing of note is the way the form is kept modalRather than using DoCmdOpenForm and DoCmdClose I use the form as a class and create an instance
manually (see the code in DialogBox and DialogRichbox ) I keep this instance alive until I got the formrsquos
result backIf you are interested in knowing how the form is made modal this is the code in FormDialogShowModal()
what keeps the form open until the user clicks a button
The Sleep() function is a Win32 API that stops the current process for the given number of milliseconds
This in effects hands back the control to the Operating System for a short time That way the system isstill responsive and does not consume resources when itrsquos just waiting for user input
Sample database
You can download a sample database containing all the necessary code as well as a number of testsThis version only contains the database in Microsoft Access 2007 accdb format
view plain copy to clipboard print
01 Public Function ShowModal() As VbMsgBoxResult02 03 Here we reset the result for the clicked button such as vbOK vbYes etc04 This is set in each Buttons Click event05 m_Result = -106 Wait for the user to click a button07 Do While (m_Result = -1)08 DoEvents09 Sleep 5010 Loop11 ShowModal = m_Result12 End Function
Download the EnhancedMsgBox01zip (116KB) v13 containing the ACCDB database
Code Updates
v13 17MAR2009Thanks to Henry of Access-Prode for proposing a correction to the default buttons behaviour
Updated behaviour for the default buttons They are now focused in a way that matches that of thestandard msgboxReversed the naming of the buttons on the form to make it a bit more consistent with the standardbox
v12 07SEP2008Thanks to Andy Colonna (httpwwwpcesoftcom) for uncovering the following bugs (check out his freeSpell Checker with source code)
Corrected bug in Form_FormDialogFilenameSanitize() function that would fail to remove all invalid
characters for a file nameFile name for the saved text message will be truncated to first 32 characters of message box title inForm_FormDialogMakeFriendlyFileName()
Changed the use of FollowHyperlink to ShellExecute to avoid security warningin some instances inForm_FormDialogbtCopyToFile_Click()
Corrected twips to pixel conversion bug in API_GetTextMetricsfTextWidthOrHeight() that would result
in an improperly sized dialog box when the text message was too wide
v11 08AUG2008
Corrected code for DefaultButtonDelay (thanks to Geoffrey) (was referencingwrong variable causing
self-referencing code)Corrected code for Box and RichBox to take the DefaultSavedTextFileFolder into account (the path
was previously not passed onto the dialog boxes and the text file would always be created in theapplication folder instead of the one specified by DefaultSavedTextFileFolder )
Added license notice at top of source code
v10 20MAY2008
Original version
Resources
Dissecting the MessageBox article on CodeProjectXMessageBox -- A reverse-engineered MessageBox() article on CodeProjectTextWidth-Height code demo from Stephen Lebans (great resource check it out)Pixel to Twips conversion from MSDNCopy Text to Clipboard from the excellent site The Access WebGetting Resource Strings and more from DLLs
This work is licensed under a Creative Commons Attribution 30 Unported LicenseFree for re-use in any application or tutorial providing clear credit is made about the origin of the codeand a link to this site is prominently displayed where end-users can easily access it
Entry Filed under NetBusinessDatabaseMSAccessProgramming
59 Comments Add your own
WAO
i cannot say more this is extremely good
i saw other solutions but yours surpass all others congratulations
keep on doing the good work
1Edwin Blancovitch | June 5th 2008 at 500 am
Thank you EdwinThere are plenty more that Irsquod like to do just a matter of finding the timehellip
2Renaud | June 7th 2008 at 404 pm
Simply smart Thank you Sir
3 Marvin | June 30th 2008 at 200 pm
Simply fantastic great work thank you
4 Anon | June 30th 2008 at 1159 pm
Renaud
Your website was a real find I love the enhanced message box utility for Access as well as the modaldialogs with transparent backgrounds These are awesome tools that help Access developers tocreate interfaces that have some visual appeal Thanks so much for your efforts and generosity
Ken Warthen
5 Ken Warthen | July 30th 2008 at 1014 pm
6Renaud | July 30th 2008 at 1111 pm
Thank you for your kind words Irsquom glad you found some of these articles useful
Renaud
I have briefly looked over your custom message box concept and like what I see I am curioushowever because unless I am mistaken you have implemented it in Access using standard modulesrather than as a class Is there any particular reason you didnrsquot create a class instead
Glenn
7 Glenn | July 31st 2008 at 613 pm
Hi GlennI think the main reason I didnrsquot use a class was that I wanted a drop-in replacement for thestandard MsgBoxUsing a class would have required creating an instance of it either every time thebox would be used or stored somewhere in a moduleClasses also become an issue as they cannotbe instantiated directly from a library (the way I usually re-use code) and you must end-up having aclass factory in a Module instead
It doesnrsquot mean it canrsquot be done I just donrsquot think it bring anything useful doing it in a Class asopposed to a Module in this case
Maybe Irsquom wrong and there is a better way
In that case let me know -)
8Renaud | July 31st 2008 at 656 pm
Renaud
Thanks for that Your explanation makes perfect sense and I canrsquot think of a compelling reason tosuggest that a class based alternative would be preferable Code libraries are certainly the way to gofor frequently used code
While using a class in this case doesnrsquot appear to offer an advantage over your standard moduleapproach you might be interested to know that there are a couple of ways to include classes in codelibraries such that any application using the library can create instances of the relevant classes
Glenn
9 glenn | August 1st 2008 at 1226 am
This is rather awesome Mind if I take a shot at back-grading it to Access 97
10 Moo | August 1st 2008 at 649 am
GlennI use a simple module that I call ldquoClassFactoryrdquo whose only purpose is to return an instanceof the Classes in the library Not sure if there is a better way
Mooplease be my guest I have been thinking about this recently but since I only have Access2007 testing for older version is a bit of a challenge
Adapting the code to older versions should not be difficult if you stick to plain text You will have toremove references to the ldquoTextFormatrdquo property of the txtMessage textbox as it is new inAccess2007 and used to switch between plain text and rich text
As far as I know the only way to bring rich text to older versions of Access is to use a webbrowser
11Renaud | August 1st 2008 at 957 am
control
If you manage to convert it please send me the updated database so I can host it here for all to find
Renaud
You can do without the module by manipulating the class modulersquos Instancing property The catch isthat the property sheet doesnrsquot allow the setting you need but you can run a single statement in theimmediate window to do the job See this posthttpwwwutteraccesscomforumsshowthreadedphpCat=ampNumber=1441683amppage=ampview=ampsb=5ampo=ampvc=1
Glenn
12 Glenn | August 1st 2008 at 425 pm
Hi Glennthanks for the tip
13Renaud | August 3rd 2008 at 320 pm
Renaud
I gave it a shot and without the RTF it just wouldnrsquot be the same so I chose not to pursue it anyfurther
The Access 2007 version is striking Thanks
Moo
14 Moo | August 6th 2008 at 633 am
Get a compile error when trying to run it ldquoUser defined Type not definedrdquohelliphellipDim f As NewForm_FormDialogHave the same references checked in my Access 2007 VBA Looks great Wouldlike to solve the problem to be able to use it ThanksLarry
15 Larry | August 6th 2008 at 114 pm
This is excellent Irsquove just added it to a new application and it looks far better and I like the ability tocopy the message to the clipboard It is also very good that it is non-blocking ie I can now moreeasily chuck users out of my systems if I want say after a period of inactivityA point that peoplemight find useful is that rather than replace all instances of Msgbox in your code with the wordldquoRichBoxrdquo you can rename the new RichBox function as Msgbox When your code then goes to callthe Msgbox function it then calls the new function ie the old Msgbox gets overridden and the newfunction is called instead
16 Alan Cossey | August 7th 2008 at 402 am
Larry does this happen with the demo or in your applicationHave you renamed the FormDialogif thatrsquos the case make sure to change the line where you get the error to reflect the new nameAnother possibility is security settings if yoursquore getting a security warning when opening the filemake sure you open it from a Trusted location or some functions will be disabled
Alan itrsquos a good point and it could make replacement much easier although I usually prefer to erron the side of caution and avoid overriding base functionality to avoid unintended consequences (andkeep in line with the ldquoelement of least surpriserdquo motto by making things explicit) -)
17Renaud | August 7th 2008 at 207 pm
Thanks for the great object
Out of Stack Space Error
Occurs when modifying DefaultButtonDelayTry modifying the Enable Buttons In field in sample form
Problem occurs in module ldquoDialogrdquo
Reads
Should read
Public Property Let DefaultButtonDelay(delay As Long)
If delay lt 0 Then delay = 0
DefaultButtonDelay = delay
End Property
Public Property Let DefaultButtonDelay(delay As Long)
If delay lt 0 Then delay = 0
m_DefaultButtonDelay = delay
End Property
18 Geoffrey | August 8th 2008 at 1236 am
Compile error happens in my application which is in a Trusted location Didnrsquot rename anything otherthan MsgBox changed to Box as instructed for one of my boxes Am I supposed to renamesomething else The compile error highlights the following VBA codehelliphellipDim f As NewForm_FormDialogLarry
19 Larry | August 8th 2008 at 701 am
Geoffrey good catch I have updated the code Thanks for notifying me
Larry still not sure why yoursquore getting this Could you send me a zip file of your application so I caninvestigate Send it to accessblognkadesign (replacing by and by com)
20Renaud | August 8th 2008 at 1026 am
Larryyou were missing the FormDialog in your application
I have updated the article to list the instructions on how to include the new code into your ownapplication I realised this was missing
21Renaud | August 8th 2008 at 320 pm
Success Enhanced Message Boxes are so much easier to identify when they pop up on the screenThe standard msgboxes are so bland they are almost camoflauged Thank you very muchLarry
22 Larry | August 9th 2008 at 637 am
Your code is way better that what I have written and really works as a replacement to the standardMsgBox function
23Jack Stockton | August 9th 2008 at 656 am
Would like to suggest an enhancementhellipability to specify customer text for two I often have abusiness case where I am displaying a message box asking the user if they want to replace or openthe existing
I got stuckhellip
A friend sent me the A2003 version but it now appears that the RichTextocx is blocked because ofsecurity reasons (apparently they deem it safe in A2007) I registered RICHTX32ocx 60 (SP6) underreferences but the 2003 mdb doesnrsquot compile lsquoacTextFormatHTMLRichTextrsquo is not found -- I found aregistry-patch here httpp2pwroxcomtopicaspTOPIC_ID=10894 -- doesnrsquot work on my pc
There is also a replacement by Stephan Lebans httpwwwlebanscomrichtexthtm -- registeringit didnrsquot help either
Also the png images donrsquot load -- apparently they donrsquot get included on converting -- could youinclude them separately
Any suggestions I really would like to give this replacement a try -- I do see its potential but as Idonrsquot have A2007 I canrsquot run it as such
24Jacques | August 12th 2008 at 657 am
Jacques I can only think of the webbrowser control as a replacementMay be too much overhead but itrsquos worth a tryIrsquove sent you the icons by emailLet me know if yousucceed -)
25Renaud | August 12th 2008 at 351 pm
Thank you Pretty good work
Therersquos one extension Irsquod like to implement or see implemented autowrap for long texts
Therersquos one slight problem with the code as it standshellip The Default Buttons are not set properly TheCode for this looks fine until you notice that the buttons are named in the reverse order to their usebt3 is used as button1 etcetera The rest of the code reflects this the Timer event which sets thedefault does not Easy to change in the timer event just replace each occurence of bt1 with bt3 andbt3 with bt1
Thanks againAndycr
26Andrew Craven Rohm | August 12th 2008 at 610 pm
Whow What a great enhancement for my Access Tools I just tried it and was really happy
Now therersquos a variation I would love to see A modified InputBox Could you do that too
Regards from Germany
Stefan
27 Stefan Reichelt | August 13th 2008 at 1017 pm
Will this tool work with an adp file If so what mods are necessary
28 Joey | September 20th 2008 at 245 am
29Michael Merlin | September 28th 2008 at 627 am
Joey should work perfectly fine in adp
Renaud brilliant work
Thanks for this great enhancement I donrsquot seem to be able to get any of the buttons to be thedefault button any help would be greatly appreciated
Cheers from downunderScott
30 Scott Cordwell | October 30th 2008 at 1122 am
Scott glad you find it usefulRegarding the default button itrsquos not really a feature I wanted to use as one of the points of usingthis enhanced MessageBox is to force users to stop for a second and think about the action theyneed to perform rather than just hitting ENTER or ESC without thinking as is the case with thestandard box
Irsquoll make a note of your suggestion for the next update and probably add it as an option (or a defaultthat can be disabled)
31Renaud | October 30th 2008 at 348 pm
[] Change Color of Text Hi Akilah I ran across this that might help youhttpblognkadesigncom2008ms-achellipx-replacement Bonnie httpwwwdataplus-svccom Akilahwrote gtHi is there a way to change the color of []
32Change Color of Text | keamphellip | January 19th 2009 at 1244 am
Could someone send me an A2003 version of this code This sounds like exactly what I need
33 Dan | January 27th 2009 at 358 am
Hi Renaud -- this is awesome ) Just a quick question -- is there scope to include customising thebuttons So rather than the standard vbYes vbNo etc you can customise them
34 Andy | January 29th 2009 at 302 am
I downloaded your Enhanced MsgBox and it worked great It definitely fit the bill for what I was doinguntil I created an ACCDE version for the users I end up with the error The expression you enteredhas a function name that the database canrsquot find
I have the Enhanced MsgBox getting called during an ldquoon clickrdquo event on a button by using=RichBox([field])
Any ideas
35 Ryan | February 6th 2009 at 910 am
I fixed your vbDefaultButton behavior bug in Form_Timer() can I send you the code
36Henry | February 7th 2009 at 248 am
To Ryan have you tried calling the RichBox from code rather than directly from the Onclick event
37Renaud | February 7th 2009 at 923 am
handler
To Henry yes please send the fix and I will update the code and the samples for everyone My emailis in the footer of the pageThank you
Itrsquos been a long time since Irsquove used Access and so Irsquom getting my feet re-wet Can you refresh me onsome code I would use to call it
38 Ryan | February 7th 2009 at 832 pm
Thanks for this excelent code I think it may be usful to a project I may play with later on
39Andrew | February 18th 2009 at 122 am
Great work based on details and comments I canrsquot possibly use this utility in Access 2002 can I
40 Ash | February 23rd 2009 at 1142 am
Ash thanks Unfortunately there is a major show-stopper if you want to get this to work in pre-2007 versions of Access
older versions donrsquot have rich-edit textboxes so you would probably have to rely on a webbrowsercomponent and that would change a lot
If you are OK with being limited to the plain version of the enhanced MsgBox then your only otherissue should be with displaying transparent images for the icons
41Renaud | February 23rd 2009 at 1238 pm
Have you developed the code for those of us non-Office 2007 users I have Office 2003 and wouldreally like to apply this enhancement
ThanksTom
42 Tom Dessert | March 6th 2009 at 428 am
Tom Dessert no I thought some good soul would try Irsquod be happy if someone did
My main issue is that I donrsquot have any older version of Access so I canrsquot really test theimplementation and be sure about the result Just saving the project in an older format wonrsquot workproperly at Irsquom using some A2007-specific features
43Renaud | March 9th 2009 at 1008 am
Brilliant code Renaudhellip Very helpfulhellip Thanks Irsquom old at Access but new to the type of coding youused to create the enhanced msgbox I am hoping to use your code to allow users to activate customhelp files from a Help button in some dialogs (doesnrsquot seem to work in standard Access 2007 msgbox-- just fires up the Access help even when custom help file and context are indicated)In my firstattepts to use your box I see that I can now reach the forms help file using F1 from the dialogboxbut it must be possible to use the standard Help buttonCan you help or advise pleaseRegards John
44 John White | May 13th 2009 at 323 pm
45 John White | May 13th 2009 at 715 pm
Regarding my last commenthellip Irsquove added a button in the same way as your btCopy and BtSave andput Sendkeys ldquoF1rdquo into the Click event to fire my custom help
Next issue please I like to set the mouse pointer to jump to default buttons on dialog boxes whichworks with the standard Access 2007 dialogs but not with my new good looking ones Is it possibleto obtain this behaviour on the custom dialog boxRegards John
Thanks for this excelent code fantastic hellip )
46 Uros | June 29th 2009 at 433 pm
Thank you for your hard work and the wonderful message box A quick comment I will be using thisbox to display a warning to my users that I will be terminating their connection so I can performupdates to the back end Irsquod like the Box to AutoClose after a certain period of time regardless ofuser interaction (or more likely non-interaction) I can program this in myself but it may be a usefulfeature to others as well
Thanks againMatthew Pfluger
47 Matthew Pfluger | July 23rd 2009 at 1213 am
Thanks for the great code I added a line to default the dialog caption to the application name if notitle is explicitly set
First few lines of Form_FormDialogShowModal are If m_Title ltgt ldquordquo Then caption = m_Title amp rdquo rdquo Elsecaption = CurrentDbProperties(ldquoAppTitlerdquo) End If
48 kirkrqm | August 8th 2009 at 837 pm
Hi
Tnx 4 your beautiful messagebox I only have one question is it possible to use a vbTab in themessage
With regardsMarianne
49 Marianne Berkhof | October 8th 2009 at 801 pm
Do you have an inputbox variant for this as well
If only i had the time to combine this withhttpwwwdatabasejournalcomfeaturesmsaccessarticlephp3848121Extending-the-InputBox-function-for-MS-Access-Formshtm
Spare time Anybody
50 Lxocram | December 18th 2009 at 457 pm
Sir this is most excellent Thanks for sharing
51 David | February 13th 2010 at 953 pm
I have downloaded your example database Irsquom using Access 2007 but something odd happens Nonof the buttons on the test form seems to activate a trigger In short nothing happens Do you havean explaination for that
52 John | February 16th 2010 at 429 pm
I would like to use vba code to close a message boc programmatically as Matthew Pfluger suggesthe can do in his July 23rd 2009 message Can someone please tell me how to do this
I too am an avid user of your message box replacement
Thanks Bob Robinson
53Bob Robinson | April 16th 2010 at 857 pm
This looks very useful could you please post the source code so those of us not using 2007 can havea go at extracting those parts that will work in earlier versions
Many Thanks
Dave
54 Dave | May 25th 2010 at 1008 pm
[] found the custom message boxes at httpblognkadesigncom2008ms-achellipx-replacement andedited it to fit my needs mdash Background colours borders etc as well as the Images []
55Deleted Image displayed wamphellip | June 17th 2010 at 702 pm
Do you know of any similar utility for MS Excel
Ken
56 Ken Warthen | October 27th 2010 at 215 am
[] really but you can create your own httpblognkadesigncom2008ms-achellip-replacement__________________ (RG for short) aka Allan Bunch MS Access MVP -- WinXP Pro Win7 Pro- acXP[]
57MsgBox Placementamphellip | December 27th 2010 at 345 am
A nice replacement message box that solves the problem (found under Access 2010) of dialog boxesstopping being lsquomodalrsquo before the user presses a button
However the png graphics image files would really be appreciatedhellip
My app has to be capable of running under Access 2003 2007 and 2010 so to keep a similar look andfeel I need to create some bitmaps for the old version
58 Sooz | January 25th 2011 at 242 am
Superb Just came across this it has given my application a ldquofinishedrdquo look One question how do Iforce the application to close after the DialogRichBox appears I checked the example and the checkbox does not fire any code
59 Greg | February 5th 2011 at 417 am
These few settings make the enhanced message box more customizable
Large text
The standard MsgBox cannot display much text On the other hand there is no real limitation to the
amount of text the Box and RichBox can display
When the amount of information is too much to fit the maximum allowed size for the message box thetext will overflow and can be scrolled updown as necessary
Limitations of the RichBox
The RichBox version relies on the normal TextBox controlrsquos ability under Access 2007 to display RichText
wich is nothing more than lightweight HTMLBecause font size may be varying a lot in the message it becomes very difficult to accurately predict thesize of the box needed to display the whole messageShort of implementing a complete HTML engine we have to rely on some assumptions to display HTMLThe risk is that sometimes the content may not properly fit the TextBox control in some circumstancesIf you use the RichBox thoroughly try displaying your messages and tweak the HTML as necessary to
include additional lines or non-breaking spaces to ensure that the result looks goodIf you donrsquot overuse font size and donrsquot display in multiple fonts the RichBox should do the right thing
most of the timeDonrsquot overuse the RichBox to display colourful messages There is a fine line between being informative
and tasteless Keep colours and formatting where it is usefulI think that in most cases the plain text version Box is more than enough
Replacing MsgBox in existing code
As I said above replacing the standard MsgBox is easy but you need to make sure your search and
replace parameters are configured correctly
If yoursquore getting strange compile errors it may be because you forgot to tick the Find Whole Word Onlyand some of the strings containing the letter sequence ldquomsgboxrdquo were replaced in the process
If thatrsquos the case you can revert the damage by simply doing a search and replace across the wholeproject on- VbboxStyle or VbDialogBoxStyle to be replaced with VbMsgBoxStyle
- VbboxResult or VbDialogBoxResult to be replaced with VbMsgBoxResult
How it works
The code makes extensive use of Win32 API callsMost of the hard work is done in the FomDialog class form There is too much there to really go into the
details but you are welcome to have a look at the commented code
DialogDefaultSavedTextFileFolder= Ctemp
The code relies also on a utility function from Stephen Lebans used to calculate the size of of text I havemade some minor modification to that code so I would refer you to his original implementation if you areinterested in calculating TextBox sizes for forms or reports
In the code for the FormDialog I re-implement some of the expected functionalities of the MsgBox
proper arrangement of the buttons displaying of the appropriate icon etcOnce this is done we calculate the size of the textbox needed to display the whole of the messageIn the case of RichText we first use ApplicationPlainText() to convert the HTML into properly
formatted plain text We then calculate the Textbox size using a slightly larger font than needed as a wayto ensure that the content of the RichText message will fit the box in most casesOnce we know the size of the TextBox we can easily resize the form to properly display the TextBoxIf there is too much text we resize the form to its maximum permissible (70 or screen width and 90of screen height) and change some of the visual cues to let the user know the text is overflowing
One thing of note is the way the form is kept modalRather than using DoCmdOpenForm and DoCmdClose I use the form as a class and create an instance
manually (see the code in DialogBox and DialogRichbox ) I keep this instance alive until I got the formrsquos
result backIf you are interested in knowing how the form is made modal this is the code in FormDialogShowModal()
what keeps the form open until the user clicks a button
The Sleep() function is a Win32 API that stops the current process for the given number of milliseconds
This in effects hands back the control to the Operating System for a short time That way the system isstill responsive and does not consume resources when itrsquos just waiting for user input
Sample database
You can download a sample database containing all the necessary code as well as a number of testsThis version only contains the database in Microsoft Access 2007 accdb format
view plain copy to clipboard print
01 Public Function ShowModal() As VbMsgBoxResult02 03 Here we reset the result for the clicked button such as vbOK vbYes etc04 This is set in each Buttons Click event05 m_Result = -106 Wait for the user to click a button07 Do While (m_Result = -1)08 DoEvents09 Sleep 5010 Loop11 ShowModal = m_Result12 End Function
Download the EnhancedMsgBox01zip (116KB) v13 containing the ACCDB database
Code Updates
v13 17MAR2009Thanks to Henry of Access-Prode for proposing a correction to the default buttons behaviour
Updated behaviour for the default buttons They are now focused in a way that matches that of thestandard msgboxReversed the naming of the buttons on the form to make it a bit more consistent with the standardbox
v12 07SEP2008Thanks to Andy Colonna (httpwwwpcesoftcom) for uncovering the following bugs (check out his freeSpell Checker with source code)
Corrected bug in Form_FormDialogFilenameSanitize() function that would fail to remove all invalid
characters for a file nameFile name for the saved text message will be truncated to first 32 characters of message box title inForm_FormDialogMakeFriendlyFileName()
Changed the use of FollowHyperlink to ShellExecute to avoid security warningin some instances inForm_FormDialogbtCopyToFile_Click()
Corrected twips to pixel conversion bug in API_GetTextMetricsfTextWidthOrHeight() that would result
in an improperly sized dialog box when the text message was too wide
v11 08AUG2008
Corrected code for DefaultButtonDelay (thanks to Geoffrey) (was referencingwrong variable causing
self-referencing code)Corrected code for Box and RichBox to take the DefaultSavedTextFileFolder into account (the path
was previously not passed onto the dialog boxes and the text file would always be created in theapplication folder instead of the one specified by DefaultSavedTextFileFolder )
Added license notice at top of source code
v10 20MAY2008
Original version
Resources
Dissecting the MessageBox article on CodeProjectXMessageBox -- A reverse-engineered MessageBox() article on CodeProjectTextWidth-Height code demo from Stephen Lebans (great resource check it out)Pixel to Twips conversion from MSDNCopy Text to Clipboard from the excellent site The Access WebGetting Resource Strings and more from DLLs
This work is licensed under a Creative Commons Attribution 30 Unported LicenseFree for re-use in any application or tutorial providing clear credit is made about the origin of the codeand a link to this site is prominently displayed where end-users can easily access it
Entry Filed under NetBusinessDatabaseMSAccessProgramming
59 Comments Add your own
WAO
i cannot say more this is extremely good
i saw other solutions but yours surpass all others congratulations
keep on doing the good work
1Edwin Blancovitch | June 5th 2008 at 500 am
Thank you EdwinThere are plenty more that Irsquod like to do just a matter of finding the timehellip
2Renaud | June 7th 2008 at 404 pm
Simply smart Thank you Sir
3 Marvin | June 30th 2008 at 200 pm
Simply fantastic great work thank you
4 Anon | June 30th 2008 at 1159 pm
Renaud
Your website was a real find I love the enhanced message box utility for Access as well as the modaldialogs with transparent backgrounds These are awesome tools that help Access developers tocreate interfaces that have some visual appeal Thanks so much for your efforts and generosity
Ken Warthen
5 Ken Warthen | July 30th 2008 at 1014 pm
6Renaud | July 30th 2008 at 1111 pm
Thank you for your kind words Irsquom glad you found some of these articles useful
Renaud
I have briefly looked over your custom message box concept and like what I see I am curioushowever because unless I am mistaken you have implemented it in Access using standard modulesrather than as a class Is there any particular reason you didnrsquot create a class instead
Glenn
7 Glenn | July 31st 2008 at 613 pm
Hi GlennI think the main reason I didnrsquot use a class was that I wanted a drop-in replacement for thestandard MsgBoxUsing a class would have required creating an instance of it either every time thebox would be used or stored somewhere in a moduleClasses also become an issue as they cannotbe instantiated directly from a library (the way I usually re-use code) and you must end-up having aclass factory in a Module instead
It doesnrsquot mean it canrsquot be done I just donrsquot think it bring anything useful doing it in a Class asopposed to a Module in this case
Maybe Irsquom wrong and there is a better way
In that case let me know -)
8Renaud | July 31st 2008 at 656 pm
Renaud
Thanks for that Your explanation makes perfect sense and I canrsquot think of a compelling reason tosuggest that a class based alternative would be preferable Code libraries are certainly the way to gofor frequently used code
While using a class in this case doesnrsquot appear to offer an advantage over your standard moduleapproach you might be interested to know that there are a couple of ways to include classes in codelibraries such that any application using the library can create instances of the relevant classes
Glenn
9 glenn | August 1st 2008 at 1226 am
This is rather awesome Mind if I take a shot at back-grading it to Access 97
10 Moo | August 1st 2008 at 649 am
GlennI use a simple module that I call ldquoClassFactoryrdquo whose only purpose is to return an instanceof the Classes in the library Not sure if there is a better way
Mooplease be my guest I have been thinking about this recently but since I only have Access2007 testing for older version is a bit of a challenge
Adapting the code to older versions should not be difficult if you stick to plain text You will have toremove references to the ldquoTextFormatrdquo property of the txtMessage textbox as it is new inAccess2007 and used to switch between plain text and rich text
As far as I know the only way to bring rich text to older versions of Access is to use a webbrowser
11Renaud | August 1st 2008 at 957 am
control
If you manage to convert it please send me the updated database so I can host it here for all to find
Renaud
You can do without the module by manipulating the class modulersquos Instancing property The catch isthat the property sheet doesnrsquot allow the setting you need but you can run a single statement in theimmediate window to do the job See this posthttpwwwutteraccesscomforumsshowthreadedphpCat=ampNumber=1441683amppage=ampview=ampsb=5ampo=ampvc=1
Glenn
12 Glenn | August 1st 2008 at 425 pm
Hi Glennthanks for the tip
13Renaud | August 3rd 2008 at 320 pm
Renaud
I gave it a shot and without the RTF it just wouldnrsquot be the same so I chose not to pursue it anyfurther
The Access 2007 version is striking Thanks
Moo
14 Moo | August 6th 2008 at 633 am
Get a compile error when trying to run it ldquoUser defined Type not definedrdquohelliphellipDim f As NewForm_FormDialogHave the same references checked in my Access 2007 VBA Looks great Wouldlike to solve the problem to be able to use it ThanksLarry
15 Larry | August 6th 2008 at 114 pm
This is excellent Irsquove just added it to a new application and it looks far better and I like the ability tocopy the message to the clipboard It is also very good that it is non-blocking ie I can now moreeasily chuck users out of my systems if I want say after a period of inactivityA point that peoplemight find useful is that rather than replace all instances of Msgbox in your code with the wordldquoRichBoxrdquo you can rename the new RichBox function as Msgbox When your code then goes to callthe Msgbox function it then calls the new function ie the old Msgbox gets overridden and the newfunction is called instead
16 Alan Cossey | August 7th 2008 at 402 am
Larry does this happen with the demo or in your applicationHave you renamed the FormDialogif thatrsquos the case make sure to change the line where you get the error to reflect the new nameAnother possibility is security settings if yoursquore getting a security warning when opening the filemake sure you open it from a Trusted location or some functions will be disabled
Alan itrsquos a good point and it could make replacement much easier although I usually prefer to erron the side of caution and avoid overriding base functionality to avoid unintended consequences (andkeep in line with the ldquoelement of least surpriserdquo motto by making things explicit) -)
17Renaud | August 7th 2008 at 207 pm
Thanks for the great object
Out of Stack Space Error
Occurs when modifying DefaultButtonDelayTry modifying the Enable Buttons In field in sample form
Problem occurs in module ldquoDialogrdquo
Reads
Should read
Public Property Let DefaultButtonDelay(delay As Long)
If delay lt 0 Then delay = 0
DefaultButtonDelay = delay
End Property
Public Property Let DefaultButtonDelay(delay As Long)
If delay lt 0 Then delay = 0
m_DefaultButtonDelay = delay
End Property
18 Geoffrey | August 8th 2008 at 1236 am
Compile error happens in my application which is in a Trusted location Didnrsquot rename anything otherthan MsgBox changed to Box as instructed for one of my boxes Am I supposed to renamesomething else The compile error highlights the following VBA codehelliphellipDim f As NewForm_FormDialogLarry
19 Larry | August 8th 2008 at 701 am
Geoffrey good catch I have updated the code Thanks for notifying me
Larry still not sure why yoursquore getting this Could you send me a zip file of your application so I caninvestigate Send it to accessblognkadesign (replacing by and by com)
20Renaud | August 8th 2008 at 1026 am
Larryyou were missing the FormDialog in your application
I have updated the article to list the instructions on how to include the new code into your ownapplication I realised this was missing
21Renaud | August 8th 2008 at 320 pm
Success Enhanced Message Boxes are so much easier to identify when they pop up on the screenThe standard msgboxes are so bland they are almost camoflauged Thank you very muchLarry
22 Larry | August 9th 2008 at 637 am
Your code is way better that what I have written and really works as a replacement to the standardMsgBox function
23Jack Stockton | August 9th 2008 at 656 am
Would like to suggest an enhancementhellipability to specify customer text for two I often have abusiness case where I am displaying a message box asking the user if they want to replace or openthe existing
I got stuckhellip
A friend sent me the A2003 version but it now appears that the RichTextocx is blocked because ofsecurity reasons (apparently they deem it safe in A2007) I registered RICHTX32ocx 60 (SP6) underreferences but the 2003 mdb doesnrsquot compile lsquoacTextFormatHTMLRichTextrsquo is not found -- I found aregistry-patch here httpp2pwroxcomtopicaspTOPIC_ID=10894 -- doesnrsquot work on my pc
There is also a replacement by Stephan Lebans httpwwwlebanscomrichtexthtm -- registeringit didnrsquot help either
Also the png images donrsquot load -- apparently they donrsquot get included on converting -- could youinclude them separately
Any suggestions I really would like to give this replacement a try -- I do see its potential but as Idonrsquot have A2007 I canrsquot run it as such
24Jacques | August 12th 2008 at 657 am
Jacques I can only think of the webbrowser control as a replacementMay be too much overhead but itrsquos worth a tryIrsquove sent you the icons by emailLet me know if yousucceed -)
25Renaud | August 12th 2008 at 351 pm
Thank you Pretty good work
Therersquos one extension Irsquod like to implement or see implemented autowrap for long texts
Therersquos one slight problem with the code as it standshellip The Default Buttons are not set properly TheCode for this looks fine until you notice that the buttons are named in the reverse order to their usebt3 is used as button1 etcetera The rest of the code reflects this the Timer event which sets thedefault does not Easy to change in the timer event just replace each occurence of bt1 with bt3 andbt3 with bt1
Thanks againAndycr
26Andrew Craven Rohm | August 12th 2008 at 610 pm
Whow What a great enhancement for my Access Tools I just tried it and was really happy
Now therersquos a variation I would love to see A modified InputBox Could you do that too
Regards from Germany
Stefan
27 Stefan Reichelt | August 13th 2008 at 1017 pm
Will this tool work with an adp file If so what mods are necessary
28 Joey | September 20th 2008 at 245 am
29Michael Merlin | September 28th 2008 at 627 am
Joey should work perfectly fine in adp
Renaud brilliant work
Thanks for this great enhancement I donrsquot seem to be able to get any of the buttons to be thedefault button any help would be greatly appreciated
Cheers from downunderScott
30 Scott Cordwell | October 30th 2008 at 1122 am
Scott glad you find it usefulRegarding the default button itrsquos not really a feature I wanted to use as one of the points of usingthis enhanced MessageBox is to force users to stop for a second and think about the action theyneed to perform rather than just hitting ENTER or ESC without thinking as is the case with thestandard box
Irsquoll make a note of your suggestion for the next update and probably add it as an option (or a defaultthat can be disabled)
31Renaud | October 30th 2008 at 348 pm
[] Change Color of Text Hi Akilah I ran across this that might help youhttpblognkadesigncom2008ms-achellipx-replacement Bonnie httpwwwdataplus-svccom Akilahwrote gtHi is there a way to change the color of []
32Change Color of Text | keamphellip | January 19th 2009 at 1244 am
Could someone send me an A2003 version of this code This sounds like exactly what I need
33 Dan | January 27th 2009 at 358 am
Hi Renaud -- this is awesome ) Just a quick question -- is there scope to include customising thebuttons So rather than the standard vbYes vbNo etc you can customise them
34 Andy | January 29th 2009 at 302 am
I downloaded your Enhanced MsgBox and it worked great It definitely fit the bill for what I was doinguntil I created an ACCDE version for the users I end up with the error The expression you enteredhas a function name that the database canrsquot find
I have the Enhanced MsgBox getting called during an ldquoon clickrdquo event on a button by using=RichBox([field])
Any ideas
35 Ryan | February 6th 2009 at 910 am
I fixed your vbDefaultButton behavior bug in Form_Timer() can I send you the code
36Henry | February 7th 2009 at 248 am
To Ryan have you tried calling the RichBox from code rather than directly from the Onclick event
37Renaud | February 7th 2009 at 923 am
handler
To Henry yes please send the fix and I will update the code and the samples for everyone My emailis in the footer of the pageThank you
Itrsquos been a long time since Irsquove used Access and so Irsquom getting my feet re-wet Can you refresh me onsome code I would use to call it
38 Ryan | February 7th 2009 at 832 pm
Thanks for this excelent code I think it may be usful to a project I may play with later on
39Andrew | February 18th 2009 at 122 am
Great work based on details and comments I canrsquot possibly use this utility in Access 2002 can I
40 Ash | February 23rd 2009 at 1142 am
Ash thanks Unfortunately there is a major show-stopper if you want to get this to work in pre-2007 versions of Access
older versions donrsquot have rich-edit textboxes so you would probably have to rely on a webbrowsercomponent and that would change a lot
If you are OK with being limited to the plain version of the enhanced MsgBox then your only otherissue should be with displaying transparent images for the icons
41Renaud | February 23rd 2009 at 1238 pm
Have you developed the code for those of us non-Office 2007 users I have Office 2003 and wouldreally like to apply this enhancement
ThanksTom
42 Tom Dessert | March 6th 2009 at 428 am
Tom Dessert no I thought some good soul would try Irsquod be happy if someone did
My main issue is that I donrsquot have any older version of Access so I canrsquot really test theimplementation and be sure about the result Just saving the project in an older format wonrsquot workproperly at Irsquom using some A2007-specific features
43Renaud | March 9th 2009 at 1008 am
Brilliant code Renaudhellip Very helpfulhellip Thanks Irsquom old at Access but new to the type of coding youused to create the enhanced msgbox I am hoping to use your code to allow users to activate customhelp files from a Help button in some dialogs (doesnrsquot seem to work in standard Access 2007 msgbox-- just fires up the Access help even when custom help file and context are indicated)In my firstattepts to use your box I see that I can now reach the forms help file using F1 from the dialogboxbut it must be possible to use the standard Help buttonCan you help or advise pleaseRegards John
44 John White | May 13th 2009 at 323 pm
45 John White | May 13th 2009 at 715 pm
Regarding my last commenthellip Irsquove added a button in the same way as your btCopy and BtSave andput Sendkeys ldquoF1rdquo into the Click event to fire my custom help
Next issue please I like to set the mouse pointer to jump to default buttons on dialog boxes whichworks with the standard Access 2007 dialogs but not with my new good looking ones Is it possibleto obtain this behaviour on the custom dialog boxRegards John
Thanks for this excelent code fantastic hellip )
46 Uros | June 29th 2009 at 433 pm
Thank you for your hard work and the wonderful message box A quick comment I will be using thisbox to display a warning to my users that I will be terminating their connection so I can performupdates to the back end Irsquod like the Box to AutoClose after a certain period of time regardless ofuser interaction (or more likely non-interaction) I can program this in myself but it may be a usefulfeature to others as well
Thanks againMatthew Pfluger
47 Matthew Pfluger | July 23rd 2009 at 1213 am
Thanks for the great code I added a line to default the dialog caption to the application name if notitle is explicitly set
First few lines of Form_FormDialogShowModal are If m_Title ltgt ldquordquo Then caption = m_Title amp rdquo rdquo Elsecaption = CurrentDbProperties(ldquoAppTitlerdquo) End If
48 kirkrqm | August 8th 2009 at 837 pm
Hi
Tnx 4 your beautiful messagebox I only have one question is it possible to use a vbTab in themessage
With regardsMarianne
49 Marianne Berkhof | October 8th 2009 at 801 pm
Do you have an inputbox variant for this as well
If only i had the time to combine this withhttpwwwdatabasejournalcomfeaturesmsaccessarticlephp3848121Extending-the-InputBox-function-for-MS-Access-Formshtm
Spare time Anybody
50 Lxocram | December 18th 2009 at 457 pm
Sir this is most excellent Thanks for sharing
51 David | February 13th 2010 at 953 pm
I have downloaded your example database Irsquom using Access 2007 but something odd happens Nonof the buttons on the test form seems to activate a trigger In short nothing happens Do you havean explaination for that
52 John | February 16th 2010 at 429 pm
I would like to use vba code to close a message boc programmatically as Matthew Pfluger suggesthe can do in his July 23rd 2009 message Can someone please tell me how to do this
I too am an avid user of your message box replacement
Thanks Bob Robinson
53Bob Robinson | April 16th 2010 at 857 pm
This looks very useful could you please post the source code so those of us not using 2007 can havea go at extracting those parts that will work in earlier versions
Many Thanks
Dave
54 Dave | May 25th 2010 at 1008 pm
[] found the custom message boxes at httpblognkadesigncom2008ms-achellipx-replacement andedited it to fit my needs mdash Background colours borders etc as well as the Images []
55Deleted Image displayed wamphellip | June 17th 2010 at 702 pm
Do you know of any similar utility for MS Excel
Ken
56 Ken Warthen | October 27th 2010 at 215 am
[] really but you can create your own httpblognkadesigncom2008ms-achellip-replacement__________________ (RG for short) aka Allan Bunch MS Access MVP -- WinXP Pro Win7 Pro- acXP[]
57MsgBox Placementamphellip | December 27th 2010 at 345 am
A nice replacement message box that solves the problem (found under Access 2010) of dialog boxesstopping being lsquomodalrsquo before the user presses a button
However the png graphics image files would really be appreciatedhellip
My app has to be capable of running under Access 2003 2007 and 2010 so to keep a similar look andfeel I need to create some bitmaps for the old version
58 Sooz | January 25th 2011 at 242 am
Superb Just came across this it has given my application a ldquofinishedrdquo look One question how do Iforce the application to close after the DialogRichBox appears I checked the example and the checkbox does not fire any code
59 Greg | February 5th 2011 at 417 am
The code relies also on a utility function from Stephen Lebans used to calculate the size of of text I havemade some minor modification to that code so I would refer you to his original implementation if you areinterested in calculating TextBox sizes for forms or reports
In the code for the FormDialog I re-implement some of the expected functionalities of the MsgBox
proper arrangement of the buttons displaying of the appropriate icon etcOnce this is done we calculate the size of the textbox needed to display the whole of the messageIn the case of RichText we first use ApplicationPlainText() to convert the HTML into properly
formatted plain text We then calculate the Textbox size using a slightly larger font than needed as a wayto ensure that the content of the RichText message will fit the box in most casesOnce we know the size of the TextBox we can easily resize the form to properly display the TextBoxIf there is too much text we resize the form to its maximum permissible (70 or screen width and 90of screen height) and change some of the visual cues to let the user know the text is overflowing
One thing of note is the way the form is kept modalRather than using DoCmdOpenForm and DoCmdClose I use the form as a class and create an instance
manually (see the code in DialogBox and DialogRichbox ) I keep this instance alive until I got the formrsquos
result backIf you are interested in knowing how the form is made modal this is the code in FormDialogShowModal()
what keeps the form open until the user clicks a button
The Sleep() function is a Win32 API that stops the current process for the given number of milliseconds
This in effects hands back the control to the Operating System for a short time That way the system isstill responsive and does not consume resources when itrsquos just waiting for user input
Sample database
You can download a sample database containing all the necessary code as well as a number of testsThis version only contains the database in Microsoft Access 2007 accdb format
view plain copy to clipboard print
01 Public Function ShowModal() As VbMsgBoxResult02 03 Here we reset the result for the clicked button such as vbOK vbYes etc04 This is set in each Buttons Click event05 m_Result = -106 Wait for the user to click a button07 Do While (m_Result = -1)08 DoEvents09 Sleep 5010 Loop11 ShowModal = m_Result12 End Function
Download the EnhancedMsgBox01zip (116KB) v13 containing the ACCDB database
Code Updates
v13 17MAR2009Thanks to Henry of Access-Prode for proposing a correction to the default buttons behaviour
Updated behaviour for the default buttons They are now focused in a way that matches that of thestandard msgboxReversed the naming of the buttons on the form to make it a bit more consistent with the standardbox
v12 07SEP2008Thanks to Andy Colonna (httpwwwpcesoftcom) for uncovering the following bugs (check out his freeSpell Checker with source code)
Corrected bug in Form_FormDialogFilenameSanitize() function that would fail to remove all invalid
characters for a file nameFile name for the saved text message will be truncated to first 32 characters of message box title inForm_FormDialogMakeFriendlyFileName()
Changed the use of FollowHyperlink to ShellExecute to avoid security warningin some instances inForm_FormDialogbtCopyToFile_Click()
Corrected twips to pixel conversion bug in API_GetTextMetricsfTextWidthOrHeight() that would result
in an improperly sized dialog box when the text message was too wide
v11 08AUG2008
Corrected code for DefaultButtonDelay (thanks to Geoffrey) (was referencingwrong variable causing
self-referencing code)Corrected code for Box and RichBox to take the DefaultSavedTextFileFolder into account (the path
was previously not passed onto the dialog boxes and the text file would always be created in theapplication folder instead of the one specified by DefaultSavedTextFileFolder )
Added license notice at top of source code
v10 20MAY2008
Original version
Resources
Dissecting the MessageBox article on CodeProjectXMessageBox -- A reverse-engineered MessageBox() article on CodeProjectTextWidth-Height code demo from Stephen Lebans (great resource check it out)Pixel to Twips conversion from MSDNCopy Text to Clipboard from the excellent site The Access WebGetting Resource Strings and more from DLLs
This work is licensed under a Creative Commons Attribution 30 Unported LicenseFree for re-use in any application or tutorial providing clear credit is made about the origin of the codeand a link to this site is prominently displayed where end-users can easily access it
Entry Filed under NetBusinessDatabaseMSAccessProgramming
59 Comments Add your own
WAO
i cannot say more this is extremely good
i saw other solutions but yours surpass all others congratulations
keep on doing the good work
1Edwin Blancovitch | June 5th 2008 at 500 am
Thank you EdwinThere are plenty more that Irsquod like to do just a matter of finding the timehellip
2Renaud | June 7th 2008 at 404 pm
Simply smart Thank you Sir
3 Marvin | June 30th 2008 at 200 pm
Simply fantastic great work thank you
4 Anon | June 30th 2008 at 1159 pm
Renaud
Your website was a real find I love the enhanced message box utility for Access as well as the modaldialogs with transparent backgrounds These are awesome tools that help Access developers tocreate interfaces that have some visual appeal Thanks so much for your efforts and generosity
Ken Warthen
5 Ken Warthen | July 30th 2008 at 1014 pm
6Renaud | July 30th 2008 at 1111 pm
Thank you for your kind words Irsquom glad you found some of these articles useful
Renaud
I have briefly looked over your custom message box concept and like what I see I am curioushowever because unless I am mistaken you have implemented it in Access using standard modulesrather than as a class Is there any particular reason you didnrsquot create a class instead
Glenn
7 Glenn | July 31st 2008 at 613 pm
Hi GlennI think the main reason I didnrsquot use a class was that I wanted a drop-in replacement for thestandard MsgBoxUsing a class would have required creating an instance of it either every time thebox would be used or stored somewhere in a moduleClasses also become an issue as they cannotbe instantiated directly from a library (the way I usually re-use code) and you must end-up having aclass factory in a Module instead
It doesnrsquot mean it canrsquot be done I just donrsquot think it bring anything useful doing it in a Class asopposed to a Module in this case
Maybe Irsquom wrong and there is a better way
In that case let me know -)
8Renaud | July 31st 2008 at 656 pm
Renaud
Thanks for that Your explanation makes perfect sense and I canrsquot think of a compelling reason tosuggest that a class based alternative would be preferable Code libraries are certainly the way to gofor frequently used code
While using a class in this case doesnrsquot appear to offer an advantage over your standard moduleapproach you might be interested to know that there are a couple of ways to include classes in codelibraries such that any application using the library can create instances of the relevant classes
Glenn
9 glenn | August 1st 2008 at 1226 am
This is rather awesome Mind if I take a shot at back-grading it to Access 97
10 Moo | August 1st 2008 at 649 am
GlennI use a simple module that I call ldquoClassFactoryrdquo whose only purpose is to return an instanceof the Classes in the library Not sure if there is a better way
Mooplease be my guest I have been thinking about this recently but since I only have Access2007 testing for older version is a bit of a challenge
Adapting the code to older versions should not be difficult if you stick to plain text You will have toremove references to the ldquoTextFormatrdquo property of the txtMessage textbox as it is new inAccess2007 and used to switch between plain text and rich text
As far as I know the only way to bring rich text to older versions of Access is to use a webbrowser
11Renaud | August 1st 2008 at 957 am
control
If you manage to convert it please send me the updated database so I can host it here for all to find
Renaud
You can do without the module by manipulating the class modulersquos Instancing property The catch isthat the property sheet doesnrsquot allow the setting you need but you can run a single statement in theimmediate window to do the job See this posthttpwwwutteraccesscomforumsshowthreadedphpCat=ampNumber=1441683amppage=ampview=ampsb=5ampo=ampvc=1
Glenn
12 Glenn | August 1st 2008 at 425 pm
Hi Glennthanks for the tip
13Renaud | August 3rd 2008 at 320 pm
Renaud
I gave it a shot and without the RTF it just wouldnrsquot be the same so I chose not to pursue it anyfurther
The Access 2007 version is striking Thanks
Moo
14 Moo | August 6th 2008 at 633 am
Get a compile error when trying to run it ldquoUser defined Type not definedrdquohelliphellipDim f As NewForm_FormDialogHave the same references checked in my Access 2007 VBA Looks great Wouldlike to solve the problem to be able to use it ThanksLarry
15 Larry | August 6th 2008 at 114 pm
This is excellent Irsquove just added it to a new application and it looks far better and I like the ability tocopy the message to the clipboard It is also very good that it is non-blocking ie I can now moreeasily chuck users out of my systems if I want say after a period of inactivityA point that peoplemight find useful is that rather than replace all instances of Msgbox in your code with the wordldquoRichBoxrdquo you can rename the new RichBox function as Msgbox When your code then goes to callthe Msgbox function it then calls the new function ie the old Msgbox gets overridden and the newfunction is called instead
16 Alan Cossey | August 7th 2008 at 402 am
Larry does this happen with the demo or in your applicationHave you renamed the FormDialogif thatrsquos the case make sure to change the line where you get the error to reflect the new nameAnother possibility is security settings if yoursquore getting a security warning when opening the filemake sure you open it from a Trusted location or some functions will be disabled
Alan itrsquos a good point and it could make replacement much easier although I usually prefer to erron the side of caution and avoid overriding base functionality to avoid unintended consequences (andkeep in line with the ldquoelement of least surpriserdquo motto by making things explicit) -)
17Renaud | August 7th 2008 at 207 pm
Thanks for the great object
Out of Stack Space Error
Occurs when modifying DefaultButtonDelayTry modifying the Enable Buttons In field in sample form
Problem occurs in module ldquoDialogrdquo
Reads
Should read
Public Property Let DefaultButtonDelay(delay As Long)
If delay lt 0 Then delay = 0
DefaultButtonDelay = delay
End Property
Public Property Let DefaultButtonDelay(delay As Long)
If delay lt 0 Then delay = 0
m_DefaultButtonDelay = delay
End Property
18 Geoffrey | August 8th 2008 at 1236 am
Compile error happens in my application which is in a Trusted location Didnrsquot rename anything otherthan MsgBox changed to Box as instructed for one of my boxes Am I supposed to renamesomething else The compile error highlights the following VBA codehelliphellipDim f As NewForm_FormDialogLarry
19 Larry | August 8th 2008 at 701 am
Geoffrey good catch I have updated the code Thanks for notifying me
Larry still not sure why yoursquore getting this Could you send me a zip file of your application so I caninvestigate Send it to accessblognkadesign (replacing by and by com)
20Renaud | August 8th 2008 at 1026 am
Larryyou were missing the FormDialog in your application
I have updated the article to list the instructions on how to include the new code into your ownapplication I realised this was missing
21Renaud | August 8th 2008 at 320 pm
Success Enhanced Message Boxes are so much easier to identify when they pop up on the screenThe standard msgboxes are so bland they are almost camoflauged Thank you very muchLarry
22 Larry | August 9th 2008 at 637 am
Your code is way better that what I have written and really works as a replacement to the standardMsgBox function
23Jack Stockton | August 9th 2008 at 656 am
Would like to suggest an enhancementhellipability to specify customer text for two I often have abusiness case where I am displaying a message box asking the user if they want to replace or openthe existing
I got stuckhellip
A friend sent me the A2003 version but it now appears that the RichTextocx is blocked because ofsecurity reasons (apparently they deem it safe in A2007) I registered RICHTX32ocx 60 (SP6) underreferences but the 2003 mdb doesnrsquot compile lsquoacTextFormatHTMLRichTextrsquo is not found -- I found aregistry-patch here httpp2pwroxcomtopicaspTOPIC_ID=10894 -- doesnrsquot work on my pc
There is also a replacement by Stephan Lebans httpwwwlebanscomrichtexthtm -- registeringit didnrsquot help either
Also the png images donrsquot load -- apparently they donrsquot get included on converting -- could youinclude them separately
Any suggestions I really would like to give this replacement a try -- I do see its potential but as Idonrsquot have A2007 I canrsquot run it as such
24Jacques | August 12th 2008 at 657 am
Jacques I can only think of the webbrowser control as a replacementMay be too much overhead but itrsquos worth a tryIrsquove sent you the icons by emailLet me know if yousucceed -)
25Renaud | August 12th 2008 at 351 pm
Thank you Pretty good work
Therersquos one extension Irsquod like to implement or see implemented autowrap for long texts
Therersquos one slight problem with the code as it standshellip The Default Buttons are not set properly TheCode for this looks fine until you notice that the buttons are named in the reverse order to their usebt3 is used as button1 etcetera The rest of the code reflects this the Timer event which sets thedefault does not Easy to change in the timer event just replace each occurence of bt1 with bt3 andbt3 with bt1
Thanks againAndycr
26Andrew Craven Rohm | August 12th 2008 at 610 pm
Whow What a great enhancement for my Access Tools I just tried it and was really happy
Now therersquos a variation I would love to see A modified InputBox Could you do that too
Regards from Germany
Stefan
27 Stefan Reichelt | August 13th 2008 at 1017 pm
Will this tool work with an adp file If so what mods are necessary
28 Joey | September 20th 2008 at 245 am
29Michael Merlin | September 28th 2008 at 627 am
Joey should work perfectly fine in adp
Renaud brilliant work
Thanks for this great enhancement I donrsquot seem to be able to get any of the buttons to be thedefault button any help would be greatly appreciated
Cheers from downunderScott
30 Scott Cordwell | October 30th 2008 at 1122 am
Scott glad you find it usefulRegarding the default button itrsquos not really a feature I wanted to use as one of the points of usingthis enhanced MessageBox is to force users to stop for a second and think about the action theyneed to perform rather than just hitting ENTER or ESC without thinking as is the case with thestandard box
Irsquoll make a note of your suggestion for the next update and probably add it as an option (or a defaultthat can be disabled)
31Renaud | October 30th 2008 at 348 pm
[] Change Color of Text Hi Akilah I ran across this that might help youhttpblognkadesigncom2008ms-achellipx-replacement Bonnie httpwwwdataplus-svccom Akilahwrote gtHi is there a way to change the color of []
32Change Color of Text | keamphellip | January 19th 2009 at 1244 am
Could someone send me an A2003 version of this code This sounds like exactly what I need
33 Dan | January 27th 2009 at 358 am
Hi Renaud -- this is awesome ) Just a quick question -- is there scope to include customising thebuttons So rather than the standard vbYes vbNo etc you can customise them
34 Andy | January 29th 2009 at 302 am
I downloaded your Enhanced MsgBox and it worked great It definitely fit the bill for what I was doinguntil I created an ACCDE version for the users I end up with the error The expression you enteredhas a function name that the database canrsquot find
I have the Enhanced MsgBox getting called during an ldquoon clickrdquo event on a button by using=RichBox([field])
Any ideas
35 Ryan | February 6th 2009 at 910 am
I fixed your vbDefaultButton behavior bug in Form_Timer() can I send you the code
36Henry | February 7th 2009 at 248 am
To Ryan have you tried calling the RichBox from code rather than directly from the Onclick event
37Renaud | February 7th 2009 at 923 am
handler
To Henry yes please send the fix and I will update the code and the samples for everyone My emailis in the footer of the pageThank you
Itrsquos been a long time since Irsquove used Access and so Irsquom getting my feet re-wet Can you refresh me onsome code I would use to call it
38 Ryan | February 7th 2009 at 832 pm
Thanks for this excelent code I think it may be usful to a project I may play with later on
39Andrew | February 18th 2009 at 122 am
Great work based on details and comments I canrsquot possibly use this utility in Access 2002 can I
40 Ash | February 23rd 2009 at 1142 am
Ash thanks Unfortunately there is a major show-stopper if you want to get this to work in pre-2007 versions of Access
older versions donrsquot have rich-edit textboxes so you would probably have to rely on a webbrowsercomponent and that would change a lot
If you are OK with being limited to the plain version of the enhanced MsgBox then your only otherissue should be with displaying transparent images for the icons
41Renaud | February 23rd 2009 at 1238 pm
Have you developed the code for those of us non-Office 2007 users I have Office 2003 and wouldreally like to apply this enhancement
ThanksTom
42 Tom Dessert | March 6th 2009 at 428 am
Tom Dessert no I thought some good soul would try Irsquod be happy if someone did
My main issue is that I donrsquot have any older version of Access so I canrsquot really test theimplementation and be sure about the result Just saving the project in an older format wonrsquot workproperly at Irsquom using some A2007-specific features
43Renaud | March 9th 2009 at 1008 am
Brilliant code Renaudhellip Very helpfulhellip Thanks Irsquom old at Access but new to the type of coding youused to create the enhanced msgbox I am hoping to use your code to allow users to activate customhelp files from a Help button in some dialogs (doesnrsquot seem to work in standard Access 2007 msgbox-- just fires up the Access help even when custom help file and context are indicated)In my firstattepts to use your box I see that I can now reach the forms help file using F1 from the dialogboxbut it must be possible to use the standard Help buttonCan you help or advise pleaseRegards John
44 John White | May 13th 2009 at 323 pm
45 John White | May 13th 2009 at 715 pm
Regarding my last commenthellip Irsquove added a button in the same way as your btCopy and BtSave andput Sendkeys ldquoF1rdquo into the Click event to fire my custom help
Next issue please I like to set the mouse pointer to jump to default buttons on dialog boxes whichworks with the standard Access 2007 dialogs but not with my new good looking ones Is it possibleto obtain this behaviour on the custom dialog boxRegards John
Thanks for this excelent code fantastic hellip )
46 Uros | June 29th 2009 at 433 pm
Thank you for your hard work and the wonderful message box A quick comment I will be using thisbox to display a warning to my users that I will be terminating their connection so I can performupdates to the back end Irsquod like the Box to AutoClose after a certain period of time regardless ofuser interaction (or more likely non-interaction) I can program this in myself but it may be a usefulfeature to others as well
Thanks againMatthew Pfluger
47 Matthew Pfluger | July 23rd 2009 at 1213 am
Thanks for the great code I added a line to default the dialog caption to the application name if notitle is explicitly set
First few lines of Form_FormDialogShowModal are If m_Title ltgt ldquordquo Then caption = m_Title amp rdquo rdquo Elsecaption = CurrentDbProperties(ldquoAppTitlerdquo) End If
48 kirkrqm | August 8th 2009 at 837 pm
Hi
Tnx 4 your beautiful messagebox I only have one question is it possible to use a vbTab in themessage
With regardsMarianne
49 Marianne Berkhof | October 8th 2009 at 801 pm
Do you have an inputbox variant for this as well
If only i had the time to combine this withhttpwwwdatabasejournalcomfeaturesmsaccessarticlephp3848121Extending-the-InputBox-function-for-MS-Access-Formshtm
Spare time Anybody
50 Lxocram | December 18th 2009 at 457 pm
Sir this is most excellent Thanks for sharing
51 David | February 13th 2010 at 953 pm
I have downloaded your example database Irsquom using Access 2007 but something odd happens Nonof the buttons on the test form seems to activate a trigger In short nothing happens Do you havean explaination for that
52 John | February 16th 2010 at 429 pm
I would like to use vba code to close a message boc programmatically as Matthew Pfluger suggesthe can do in his July 23rd 2009 message Can someone please tell me how to do this
I too am an avid user of your message box replacement
Thanks Bob Robinson
53Bob Robinson | April 16th 2010 at 857 pm
This looks very useful could you please post the source code so those of us not using 2007 can havea go at extracting those parts that will work in earlier versions
Many Thanks
Dave
54 Dave | May 25th 2010 at 1008 pm
[] found the custom message boxes at httpblognkadesigncom2008ms-achellipx-replacement andedited it to fit my needs mdash Background colours borders etc as well as the Images []
55Deleted Image displayed wamphellip | June 17th 2010 at 702 pm
Do you know of any similar utility for MS Excel
Ken
56 Ken Warthen | October 27th 2010 at 215 am
[] really but you can create your own httpblognkadesigncom2008ms-achellip-replacement__________________ (RG for short) aka Allan Bunch MS Access MVP -- WinXP Pro Win7 Pro- acXP[]
57MsgBox Placementamphellip | December 27th 2010 at 345 am
A nice replacement message box that solves the problem (found under Access 2010) of dialog boxesstopping being lsquomodalrsquo before the user presses a button
However the png graphics image files would really be appreciatedhellip
My app has to be capable of running under Access 2003 2007 and 2010 so to keep a similar look andfeel I need to create some bitmaps for the old version
58 Sooz | January 25th 2011 at 242 am
Superb Just came across this it has given my application a ldquofinishedrdquo look One question how do Iforce the application to close after the DialogRichBox appears I checked the example and the checkbox does not fire any code
59 Greg | February 5th 2011 at 417 am
Download the EnhancedMsgBox01zip (116KB) v13 containing the ACCDB database
Code Updates
v13 17MAR2009Thanks to Henry of Access-Prode for proposing a correction to the default buttons behaviour
Updated behaviour for the default buttons They are now focused in a way that matches that of thestandard msgboxReversed the naming of the buttons on the form to make it a bit more consistent with the standardbox
v12 07SEP2008Thanks to Andy Colonna (httpwwwpcesoftcom) for uncovering the following bugs (check out his freeSpell Checker with source code)
Corrected bug in Form_FormDialogFilenameSanitize() function that would fail to remove all invalid
characters for a file nameFile name for the saved text message will be truncated to first 32 characters of message box title inForm_FormDialogMakeFriendlyFileName()
Changed the use of FollowHyperlink to ShellExecute to avoid security warningin some instances inForm_FormDialogbtCopyToFile_Click()
Corrected twips to pixel conversion bug in API_GetTextMetricsfTextWidthOrHeight() that would result
in an improperly sized dialog box when the text message was too wide
v11 08AUG2008
Corrected code for DefaultButtonDelay (thanks to Geoffrey) (was referencingwrong variable causing
self-referencing code)Corrected code for Box and RichBox to take the DefaultSavedTextFileFolder into account (the path
was previously not passed onto the dialog boxes and the text file would always be created in theapplication folder instead of the one specified by DefaultSavedTextFileFolder )
Added license notice at top of source code
v10 20MAY2008
Original version
Resources
Dissecting the MessageBox article on CodeProjectXMessageBox -- A reverse-engineered MessageBox() article on CodeProjectTextWidth-Height code demo from Stephen Lebans (great resource check it out)Pixel to Twips conversion from MSDNCopy Text to Clipboard from the excellent site The Access WebGetting Resource Strings and more from DLLs
This work is licensed under a Creative Commons Attribution 30 Unported LicenseFree for re-use in any application or tutorial providing clear credit is made about the origin of the codeand a link to this site is prominently displayed where end-users can easily access it
Entry Filed under NetBusinessDatabaseMSAccessProgramming
59 Comments Add your own
WAO
i cannot say more this is extremely good
i saw other solutions but yours surpass all others congratulations
keep on doing the good work
1Edwin Blancovitch | June 5th 2008 at 500 am
Thank you EdwinThere are plenty more that Irsquod like to do just a matter of finding the timehellip
2Renaud | June 7th 2008 at 404 pm
Simply smart Thank you Sir
3 Marvin | June 30th 2008 at 200 pm
Simply fantastic great work thank you
4 Anon | June 30th 2008 at 1159 pm
Renaud
Your website was a real find I love the enhanced message box utility for Access as well as the modaldialogs with transparent backgrounds These are awesome tools that help Access developers tocreate interfaces that have some visual appeal Thanks so much for your efforts and generosity
Ken Warthen
5 Ken Warthen | July 30th 2008 at 1014 pm
6Renaud | July 30th 2008 at 1111 pm
Thank you for your kind words Irsquom glad you found some of these articles useful
Renaud
I have briefly looked over your custom message box concept and like what I see I am curioushowever because unless I am mistaken you have implemented it in Access using standard modulesrather than as a class Is there any particular reason you didnrsquot create a class instead
Glenn
7 Glenn | July 31st 2008 at 613 pm
Hi GlennI think the main reason I didnrsquot use a class was that I wanted a drop-in replacement for thestandard MsgBoxUsing a class would have required creating an instance of it either every time thebox would be used or stored somewhere in a moduleClasses also become an issue as they cannotbe instantiated directly from a library (the way I usually re-use code) and you must end-up having aclass factory in a Module instead
It doesnrsquot mean it canrsquot be done I just donrsquot think it bring anything useful doing it in a Class asopposed to a Module in this case
Maybe Irsquom wrong and there is a better way
In that case let me know -)
8Renaud | July 31st 2008 at 656 pm
Renaud
Thanks for that Your explanation makes perfect sense and I canrsquot think of a compelling reason tosuggest that a class based alternative would be preferable Code libraries are certainly the way to gofor frequently used code
While using a class in this case doesnrsquot appear to offer an advantage over your standard moduleapproach you might be interested to know that there are a couple of ways to include classes in codelibraries such that any application using the library can create instances of the relevant classes
Glenn
9 glenn | August 1st 2008 at 1226 am
This is rather awesome Mind if I take a shot at back-grading it to Access 97
10 Moo | August 1st 2008 at 649 am
GlennI use a simple module that I call ldquoClassFactoryrdquo whose only purpose is to return an instanceof the Classes in the library Not sure if there is a better way
Mooplease be my guest I have been thinking about this recently but since I only have Access2007 testing for older version is a bit of a challenge
Adapting the code to older versions should not be difficult if you stick to plain text You will have toremove references to the ldquoTextFormatrdquo property of the txtMessage textbox as it is new inAccess2007 and used to switch between plain text and rich text
As far as I know the only way to bring rich text to older versions of Access is to use a webbrowser
11Renaud | August 1st 2008 at 957 am
control
If you manage to convert it please send me the updated database so I can host it here for all to find
Renaud
You can do without the module by manipulating the class modulersquos Instancing property The catch isthat the property sheet doesnrsquot allow the setting you need but you can run a single statement in theimmediate window to do the job See this posthttpwwwutteraccesscomforumsshowthreadedphpCat=ampNumber=1441683amppage=ampview=ampsb=5ampo=ampvc=1
Glenn
12 Glenn | August 1st 2008 at 425 pm
Hi Glennthanks for the tip
13Renaud | August 3rd 2008 at 320 pm
Renaud
I gave it a shot and without the RTF it just wouldnrsquot be the same so I chose not to pursue it anyfurther
The Access 2007 version is striking Thanks
Moo
14 Moo | August 6th 2008 at 633 am
Get a compile error when trying to run it ldquoUser defined Type not definedrdquohelliphellipDim f As NewForm_FormDialogHave the same references checked in my Access 2007 VBA Looks great Wouldlike to solve the problem to be able to use it ThanksLarry
15 Larry | August 6th 2008 at 114 pm
This is excellent Irsquove just added it to a new application and it looks far better and I like the ability tocopy the message to the clipboard It is also very good that it is non-blocking ie I can now moreeasily chuck users out of my systems if I want say after a period of inactivityA point that peoplemight find useful is that rather than replace all instances of Msgbox in your code with the wordldquoRichBoxrdquo you can rename the new RichBox function as Msgbox When your code then goes to callthe Msgbox function it then calls the new function ie the old Msgbox gets overridden and the newfunction is called instead
16 Alan Cossey | August 7th 2008 at 402 am
Larry does this happen with the demo or in your applicationHave you renamed the FormDialogif thatrsquos the case make sure to change the line where you get the error to reflect the new nameAnother possibility is security settings if yoursquore getting a security warning when opening the filemake sure you open it from a Trusted location or some functions will be disabled
Alan itrsquos a good point and it could make replacement much easier although I usually prefer to erron the side of caution and avoid overriding base functionality to avoid unintended consequences (andkeep in line with the ldquoelement of least surpriserdquo motto by making things explicit) -)
17Renaud | August 7th 2008 at 207 pm
Thanks for the great object
Out of Stack Space Error
Occurs when modifying DefaultButtonDelayTry modifying the Enable Buttons In field in sample form
Problem occurs in module ldquoDialogrdquo
Reads
Should read
Public Property Let DefaultButtonDelay(delay As Long)
If delay lt 0 Then delay = 0
DefaultButtonDelay = delay
End Property
Public Property Let DefaultButtonDelay(delay As Long)
If delay lt 0 Then delay = 0
m_DefaultButtonDelay = delay
End Property
18 Geoffrey | August 8th 2008 at 1236 am
Compile error happens in my application which is in a Trusted location Didnrsquot rename anything otherthan MsgBox changed to Box as instructed for one of my boxes Am I supposed to renamesomething else The compile error highlights the following VBA codehelliphellipDim f As NewForm_FormDialogLarry
19 Larry | August 8th 2008 at 701 am
Geoffrey good catch I have updated the code Thanks for notifying me
Larry still not sure why yoursquore getting this Could you send me a zip file of your application so I caninvestigate Send it to accessblognkadesign (replacing by and by com)
20Renaud | August 8th 2008 at 1026 am
Larryyou were missing the FormDialog in your application
I have updated the article to list the instructions on how to include the new code into your ownapplication I realised this was missing
21Renaud | August 8th 2008 at 320 pm
Success Enhanced Message Boxes are so much easier to identify when they pop up on the screenThe standard msgboxes are so bland they are almost camoflauged Thank you very muchLarry
22 Larry | August 9th 2008 at 637 am
Your code is way better that what I have written and really works as a replacement to the standardMsgBox function
23Jack Stockton | August 9th 2008 at 656 am
Would like to suggest an enhancementhellipability to specify customer text for two I often have abusiness case where I am displaying a message box asking the user if they want to replace or openthe existing
I got stuckhellip
A friend sent me the A2003 version but it now appears that the RichTextocx is blocked because ofsecurity reasons (apparently they deem it safe in A2007) I registered RICHTX32ocx 60 (SP6) underreferences but the 2003 mdb doesnrsquot compile lsquoacTextFormatHTMLRichTextrsquo is not found -- I found aregistry-patch here httpp2pwroxcomtopicaspTOPIC_ID=10894 -- doesnrsquot work on my pc
There is also a replacement by Stephan Lebans httpwwwlebanscomrichtexthtm -- registeringit didnrsquot help either
Also the png images donrsquot load -- apparently they donrsquot get included on converting -- could youinclude them separately
Any suggestions I really would like to give this replacement a try -- I do see its potential but as Idonrsquot have A2007 I canrsquot run it as such
24Jacques | August 12th 2008 at 657 am
Jacques I can only think of the webbrowser control as a replacementMay be too much overhead but itrsquos worth a tryIrsquove sent you the icons by emailLet me know if yousucceed -)
25Renaud | August 12th 2008 at 351 pm
Thank you Pretty good work
Therersquos one extension Irsquod like to implement or see implemented autowrap for long texts
Therersquos one slight problem with the code as it standshellip The Default Buttons are not set properly TheCode for this looks fine until you notice that the buttons are named in the reverse order to their usebt3 is used as button1 etcetera The rest of the code reflects this the Timer event which sets thedefault does not Easy to change in the timer event just replace each occurence of bt1 with bt3 andbt3 with bt1
Thanks againAndycr
26Andrew Craven Rohm | August 12th 2008 at 610 pm
Whow What a great enhancement for my Access Tools I just tried it and was really happy
Now therersquos a variation I would love to see A modified InputBox Could you do that too
Regards from Germany
Stefan
27 Stefan Reichelt | August 13th 2008 at 1017 pm
Will this tool work with an adp file If so what mods are necessary
28 Joey | September 20th 2008 at 245 am
29Michael Merlin | September 28th 2008 at 627 am
Joey should work perfectly fine in adp
Renaud brilliant work
Thanks for this great enhancement I donrsquot seem to be able to get any of the buttons to be thedefault button any help would be greatly appreciated
Cheers from downunderScott
30 Scott Cordwell | October 30th 2008 at 1122 am
Scott glad you find it usefulRegarding the default button itrsquos not really a feature I wanted to use as one of the points of usingthis enhanced MessageBox is to force users to stop for a second and think about the action theyneed to perform rather than just hitting ENTER or ESC without thinking as is the case with thestandard box
Irsquoll make a note of your suggestion for the next update and probably add it as an option (or a defaultthat can be disabled)
31Renaud | October 30th 2008 at 348 pm
[] Change Color of Text Hi Akilah I ran across this that might help youhttpblognkadesigncom2008ms-achellipx-replacement Bonnie httpwwwdataplus-svccom Akilahwrote gtHi is there a way to change the color of []
32Change Color of Text | keamphellip | January 19th 2009 at 1244 am
Could someone send me an A2003 version of this code This sounds like exactly what I need
33 Dan | January 27th 2009 at 358 am
Hi Renaud -- this is awesome ) Just a quick question -- is there scope to include customising thebuttons So rather than the standard vbYes vbNo etc you can customise them
34 Andy | January 29th 2009 at 302 am
I downloaded your Enhanced MsgBox and it worked great It definitely fit the bill for what I was doinguntil I created an ACCDE version for the users I end up with the error The expression you enteredhas a function name that the database canrsquot find
I have the Enhanced MsgBox getting called during an ldquoon clickrdquo event on a button by using=RichBox([field])
Any ideas
35 Ryan | February 6th 2009 at 910 am
I fixed your vbDefaultButton behavior bug in Form_Timer() can I send you the code
36Henry | February 7th 2009 at 248 am
To Ryan have you tried calling the RichBox from code rather than directly from the Onclick event
37Renaud | February 7th 2009 at 923 am
handler
To Henry yes please send the fix and I will update the code and the samples for everyone My emailis in the footer of the pageThank you
Itrsquos been a long time since Irsquove used Access and so Irsquom getting my feet re-wet Can you refresh me onsome code I would use to call it
38 Ryan | February 7th 2009 at 832 pm
Thanks for this excelent code I think it may be usful to a project I may play with later on
39Andrew | February 18th 2009 at 122 am
Great work based on details and comments I canrsquot possibly use this utility in Access 2002 can I
40 Ash | February 23rd 2009 at 1142 am
Ash thanks Unfortunately there is a major show-stopper if you want to get this to work in pre-2007 versions of Access
older versions donrsquot have rich-edit textboxes so you would probably have to rely on a webbrowsercomponent and that would change a lot
If you are OK with being limited to the plain version of the enhanced MsgBox then your only otherissue should be with displaying transparent images for the icons
41Renaud | February 23rd 2009 at 1238 pm
Have you developed the code for those of us non-Office 2007 users I have Office 2003 and wouldreally like to apply this enhancement
ThanksTom
42 Tom Dessert | March 6th 2009 at 428 am
Tom Dessert no I thought some good soul would try Irsquod be happy if someone did
My main issue is that I donrsquot have any older version of Access so I canrsquot really test theimplementation and be sure about the result Just saving the project in an older format wonrsquot workproperly at Irsquom using some A2007-specific features
43Renaud | March 9th 2009 at 1008 am
Brilliant code Renaudhellip Very helpfulhellip Thanks Irsquom old at Access but new to the type of coding youused to create the enhanced msgbox I am hoping to use your code to allow users to activate customhelp files from a Help button in some dialogs (doesnrsquot seem to work in standard Access 2007 msgbox-- just fires up the Access help even when custom help file and context are indicated)In my firstattepts to use your box I see that I can now reach the forms help file using F1 from the dialogboxbut it must be possible to use the standard Help buttonCan you help or advise pleaseRegards John
44 John White | May 13th 2009 at 323 pm
45 John White | May 13th 2009 at 715 pm
Regarding my last commenthellip Irsquove added a button in the same way as your btCopy and BtSave andput Sendkeys ldquoF1rdquo into the Click event to fire my custom help
Next issue please I like to set the mouse pointer to jump to default buttons on dialog boxes whichworks with the standard Access 2007 dialogs but not with my new good looking ones Is it possibleto obtain this behaviour on the custom dialog boxRegards John
Thanks for this excelent code fantastic hellip )
46 Uros | June 29th 2009 at 433 pm
Thank you for your hard work and the wonderful message box A quick comment I will be using thisbox to display a warning to my users that I will be terminating their connection so I can performupdates to the back end Irsquod like the Box to AutoClose after a certain period of time regardless ofuser interaction (or more likely non-interaction) I can program this in myself but it may be a usefulfeature to others as well
Thanks againMatthew Pfluger
47 Matthew Pfluger | July 23rd 2009 at 1213 am
Thanks for the great code I added a line to default the dialog caption to the application name if notitle is explicitly set
First few lines of Form_FormDialogShowModal are If m_Title ltgt ldquordquo Then caption = m_Title amp rdquo rdquo Elsecaption = CurrentDbProperties(ldquoAppTitlerdquo) End If
48 kirkrqm | August 8th 2009 at 837 pm
Hi
Tnx 4 your beautiful messagebox I only have one question is it possible to use a vbTab in themessage
With regardsMarianne
49 Marianne Berkhof | October 8th 2009 at 801 pm
Do you have an inputbox variant for this as well
If only i had the time to combine this withhttpwwwdatabasejournalcomfeaturesmsaccessarticlephp3848121Extending-the-InputBox-function-for-MS-Access-Formshtm
Spare time Anybody
50 Lxocram | December 18th 2009 at 457 pm
Sir this is most excellent Thanks for sharing
51 David | February 13th 2010 at 953 pm
I have downloaded your example database Irsquom using Access 2007 but something odd happens Nonof the buttons on the test form seems to activate a trigger In short nothing happens Do you havean explaination for that
52 John | February 16th 2010 at 429 pm
I would like to use vba code to close a message boc programmatically as Matthew Pfluger suggesthe can do in his July 23rd 2009 message Can someone please tell me how to do this
I too am an avid user of your message box replacement
Thanks Bob Robinson
53Bob Robinson | April 16th 2010 at 857 pm
This looks very useful could you please post the source code so those of us not using 2007 can havea go at extracting those parts that will work in earlier versions
Many Thanks
Dave
54 Dave | May 25th 2010 at 1008 pm
[] found the custom message boxes at httpblognkadesigncom2008ms-achellipx-replacement andedited it to fit my needs mdash Background colours borders etc as well as the Images []
55Deleted Image displayed wamphellip | June 17th 2010 at 702 pm
Do you know of any similar utility for MS Excel
Ken
56 Ken Warthen | October 27th 2010 at 215 am
[] really but you can create your own httpblognkadesigncom2008ms-achellip-replacement__________________ (RG for short) aka Allan Bunch MS Access MVP -- WinXP Pro Win7 Pro- acXP[]
57MsgBox Placementamphellip | December 27th 2010 at 345 am
A nice replacement message box that solves the problem (found under Access 2010) of dialog boxesstopping being lsquomodalrsquo before the user presses a button
However the png graphics image files would really be appreciatedhellip
My app has to be capable of running under Access 2003 2007 and 2010 so to keep a similar look andfeel I need to create some bitmaps for the old version
58 Sooz | January 25th 2011 at 242 am
Superb Just came across this it has given my application a ldquofinishedrdquo look One question how do Iforce the application to close after the DialogRichBox appears I checked the example and the checkbox does not fire any code
59 Greg | February 5th 2011 at 417 am
v10 20MAY2008
Original version
Resources
Dissecting the MessageBox article on CodeProjectXMessageBox -- A reverse-engineered MessageBox() article on CodeProjectTextWidth-Height code demo from Stephen Lebans (great resource check it out)Pixel to Twips conversion from MSDNCopy Text to Clipboard from the excellent site The Access WebGetting Resource Strings and more from DLLs
This work is licensed under a Creative Commons Attribution 30 Unported LicenseFree for re-use in any application or tutorial providing clear credit is made about the origin of the codeand a link to this site is prominently displayed where end-users can easily access it
Entry Filed under NetBusinessDatabaseMSAccessProgramming
59 Comments Add your own
WAO
i cannot say more this is extremely good
i saw other solutions but yours surpass all others congratulations
keep on doing the good work
1Edwin Blancovitch | June 5th 2008 at 500 am
Thank you EdwinThere are plenty more that Irsquod like to do just a matter of finding the timehellip
2Renaud | June 7th 2008 at 404 pm
Simply smart Thank you Sir
3 Marvin | June 30th 2008 at 200 pm
Simply fantastic great work thank you
4 Anon | June 30th 2008 at 1159 pm
Renaud
Your website was a real find I love the enhanced message box utility for Access as well as the modaldialogs with transparent backgrounds These are awesome tools that help Access developers tocreate interfaces that have some visual appeal Thanks so much for your efforts and generosity
Ken Warthen
5 Ken Warthen | July 30th 2008 at 1014 pm
6Renaud | July 30th 2008 at 1111 pm
Thank you for your kind words Irsquom glad you found some of these articles useful
Renaud
I have briefly looked over your custom message box concept and like what I see I am curioushowever because unless I am mistaken you have implemented it in Access using standard modulesrather than as a class Is there any particular reason you didnrsquot create a class instead
Glenn
7 Glenn | July 31st 2008 at 613 pm
Hi GlennI think the main reason I didnrsquot use a class was that I wanted a drop-in replacement for thestandard MsgBoxUsing a class would have required creating an instance of it either every time thebox would be used or stored somewhere in a moduleClasses also become an issue as they cannotbe instantiated directly from a library (the way I usually re-use code) and you must end-up having aclass factory in a Module instead
It doesnrsquot mean it canrsquot be done I just donrsquot think it bring anything useful doing it in a Class asopposed to a Module in this case
Maybe Irsquom wrong and there is a better way
In that case let me know -)
8Renaud | July 31st 2008 at 656 pm
Renaud
Thanks for that Your explanation makes perfect sense and I canrsquot think of a compelling reason tosuggest that a class based alternative would be preferable Code libraries are certainly the way to gofor frequently used code
While using a class in this case doesnrsquot appear to offer an advantage over your standard moduleapproach you might be interested to know that there are a couple of ways to include classes in codelibraries such that any application using the library can create instances of the relevant classes
Glenn
9 glenn | August 1st 2008 at 1226 am
This is rather awesome Mind if I take a shot at back-grading it to Access 97
10 Moo | August 1st 2008 at 649 am
GlennI use a simple module that I call ldquoClassFactoryrdquo whose only purpose is to return an instanceof the Classes in the library Not sure if there is a better way
Mooplease be my guest I have been thinking about this recently but since I only have Access2007 testing for older version is a bit of a challenge
Adapting the code to older versions should not be difficult if you stick to plain text You will have toremove references to the ldquoTextFormatrdquo property of the txtMessage textbox as it is new inAccess2007 and used to switch between plain text and rich text
As far as I know the only way to bring rich text to older versions of Access is to use a webbrowser
11Renaud | August 1st 2008 at 957 am
control
If you manage to convert it please send me the updated database so I can host it here for all to find
Renaud
You can do without the module by manipulating the class modulersquos Instancing property The catch isthat the property sheet doesnrsquot allow the setting you need but you can run a single statement in theimmediate window to do the job See this posthttpwwwutteraccesscomforumsshowthreadedphpCat=ampNumber=1441683amppage=ampview=ampsb=5ampo=ampvc=1
Glenn
12 Glenn | August 1st 2008 at 425 pm
Hi Glennthanks for the tip
13Renaud | August 3rd 2008 at 320 pm
Renaud
I gave it a shot and without the RTF it just wouldnrsquot be the same so I chose not to pursue it anyfurther
The Access 2007 version is striking Thanks
Moo
14 Moo | August 6th 2008 at 633 am
Get a compile error when trying to run it ldquoUser defined Type not definedrdquohelliphellipDim f As NewForm_FormDialogHave the same references checked in my Access 2007 VBA Looks great Wouldlike to solve the problem to be able to use it ThanksLarry
15 Larry | August 6th 2008 at 114 pm
This is excellent Irsquove just added it to a new application and it looks far better and I like the ability tocopy the message to the clipboard It is also very good that it is non-blocking ie I can now moreeasily chuck users out of my systems if I want say after a period of inactivityA point that peoplemight find useful is that rather than replace all instances of Msgbox in your code with the wordldquoRichBoxrdquo you can rename the new RichBox function as Msgbox When your code then goes to callthe Msgbox function it then calls the new function ie the old Msgbox gets overridden and the newfunction is called instead
16 Alan Cossey | August 7th 2008 at 402 am
Larry does this happen with the demo or in your applicationHave you renamed the FormDialogif thatrsquos the case make sure to change the line where you get the error to reflect the new nameAnother possibility is security settings if yoursquore getting a security warning when opening the filemake sure you open it from a Trusted location or some functions will be disabled
Alan itrsquos a good point and it could make replacement much easier although I usually prefer to erron the side of caution and avoid overriding base functionality to avoid unintended consequences (andkeep in line with the ldquoelement of least surpriserdquo motto by making things explicit) -)
17Renaud | August 7th 2008 at 207 pm
Thanks for the great object
Out of Stack Space Error
Occurs when modifying DefaultButtonDelayTry modifying the Enable Buttons In field in sample form
Problem occurs in module ldquoDialogrdquo
Reads
Should read
Public Property Let DefaultButtonDelay(delay As Long)
If delay lt 0 Then delay = 0
DefaultButtonDelay = delay
End Property
Public Property Let DefaultButtonDelay(delay As Long)
If delay lt 0 Then delay = 0
m_DefaultButtonDelay = delay
End Property
18 Geoffrey | August 8th 2008 at 1236 am
Compile error happens in my application which is in a Trusted location Didnrsquot rename anything otherthan MsgBox changed to Box as instructed for one of my boxes Am I supposed to renamesomething else The compile error highlights the following VBA codehelliphellipDim f As NewForm_FormDialogLarry
19 Larry | August 8th 2008 at 701 am
Geoffrey good catch I have updated the code Thanks for notifying me
Larry still not sure why yoursquore getting this Could you send me a zip file of your application so I caninvestigate Send it to accessblognkadesign (replacing by and by com)
20Renaud | August 8th 2008 at 1026 am
Larryyou were missing the FormDialog in your application
I have updated the article to list the instructions on how to include the new code into your ownapplication I realised this was missing
21Renaud | August 8th 2008 at 320 pm
Success Enhanced Message Boxes are so much easier to identify when they pop up on the screenThe standard msgboxes are so bland they are almost camoflauged Thank you very muchLarry
22 Larry | August 9th 2008 at 637 am
Your code is way better that what I have written and really works as a replacement to the standardMsgBox function
23Jack Stockton | August 9th 2008 at 656 am
Would like to suggest an enhancementhellipability to specify customer text for two I often have abusiness case where I am displaying a message box asking the user if they want to replace or openthe existing
I got stuckhellip
A friend sent me the A2003 version but it now appears that the RichTextocx is blocked because ofsecurity reasons (apparently they deem it safe in A2007) I registered RICHTX32ocx 60 (SP6) underreferences but the 2003 mdb doesnrsquot compile lsquoacTextFormatHTMLRichTextrsquo is not found -- I found aregistry-patch here httpp2pwroxcomtopicaspTOPIC_ID=10894 -- doesnrsquot work on my pc
There is also a replacement by Stephan Lebans httpwwwlebanscomrichtexthtm -- registeringit didnrsquot help either
Also the png images donrsquot load -- apparently they donrsquot get included on converting -- could youinclude them separately
Any suggestions I really would like to give this replacement a try -- I do see its potential but as Idonrsquot have A2007 I canrsquot run it as such
24Jacques | August 12th 2008 at 657 am
Jacques I can only think of the webbrowser control as a replacementMay be too much overhead but itrsquos worth a tryIrsquove sent you the icons by emailLet me know if yousucceed -)
25Renaud | August 12th 2008 at 351 pm
Thank you Pretty good work
Therersquos one extension Irsquod like to implement or see implemented autowrap for long texts
Therersquos one slight problem with the code as it standshellip The Default Buttons are not set properly TheCode for this looks fine until you notice that the buttons are named in the reverse order to their usebt3 is used as button1 etcetera The rest of the code reflects this the Timer event which sets thedefault does not Easy to change in the timer event just replace each occurence of bt1 with bt3 andbt3 with bt1
Thanks againAndycr
26Andrew Craven Rohm | August 12th 2008 at 610 pm
Whow What a great enhancement for my Access Tools I just tried it and was really happy
Now therersquos a variation I would love to see A modified InputBox Could you do that too
Regards from Germany
Stefan
27 Stefan Reichelt | August 13th 2008 at 1017 pm
Will this tool work with an adp file If so what mods are necessary
28 Joey | September 20th 2008 at 245 am
29Michael Merlin | September 28th 2008 at 627 am
Joey should work perfectly fine in adp
Renaud brilliant work
Thanks for this great enhancement I donrsquot seem to be able to get any of the buttons to be thedefault button any help would be greatly appreciated
Cheers from downunderScott
30 Scott Cordwell | October 30th 2008 at 1122 am
Scott glad you find it usefulRegarding the default button itrsquos not really a feature I wanted to use as one of the points of usingthis enhanced MessageBox is to force users to stop for a second and think about the action theyneed to perform rather than just hitting ENTER or ESC without thinking as is the case with thestandard box
Irsquoll make a note of your suggestion for the next update and probably add it as an option (or a defaultthat can be disabled)
31Renaud | October 30th 2008 at 348 pm
[] Change Color of Text Hi Akilah I ran across this that might help youhttpblognkadesigncom2008ms-achellipx-replacement Bonnie httpwwwdataplus-svccom Akilahwrote gtHi is there a way to change the color of []
32Change Color of Text | keamphellip | January 19th 2009 at 1244 am
Could someone send me an A2003 version of this code This sounds like exactly what I need
33 Dan | January 27th 2009 at 358 am
Hi Renaud -- this is awesome ) Just a quick question -- is there scope to include customising thebuttons So rather than the standard vbYes vbNo etc you can customise them
34 Andy | January 29th 2009 at 302 am
I downloaded your Enhanced MsgBox and it worked great It definitely fit the bill for what I was doinguntil I created an ACCDE version for the users I end up with the error The expression you enteredhas a function name that the database canrsquot find
I have the Enhanced MsgBox getting called during an ldquoon clickrdquo event on a button by using=RichBox([field])
Any ideas
35 Ryan | February 6th 2009 at 910 am
I fixed your vbDefaultButton behavior bug in Form_Timer() can I send you the code
36Henry | February 7th 2009 at 248 am
To Ryan have you tried calling the RichBox from code rather than directly from the Onclick event
37Renaud | February 7th 2009 at 923 am
handler
To Henry yes please send the fix and I will update the code and the samples for everyone My emailis in the footer of the pageThank you
Itrsquos been a long time since Irsquove used Access and so Irsquom getting my feet re-wet Can you refresh me onsome code I would use to call it
38 Ryan | February 7th 2009 at 832 pm
Thanks for this excelent code I think it may be usful to a project I may play with later on
39Andrew | February 18th 2009 at 122 am
Great work based on details and comments I canrsquot possibly use this utility in Access 2002 can I
40 Ash | February 23rd 2009 at 1142 am
Ash thanks Unfortunately there is a major show-stopper if you want to get this to work in pre-2007 versions of Access
older versions donrsquot have rich-edit textboxes so you would probably have to rely on a webbrowsercomponent and that would change a lot
If you are OK with being limited to the plain version of the enhanced MsgBox then your only otherissue should be with displaying transparent images for the icons
41Renaud | February 23rd 2009 at 1238 pm
Have you developed the code for those of us non-Office 2007 users I have Office 2003 and wouldreally like to apply this enhancement
ThanksTom
42 Tom Dessert | March 6th 2009 at 428 am
Tom Dessert no I thought some good soul would try Irsquod be happy if someone did
My main issue is that I donrsquot have any older version of Access so I canrsquot really test theimplementation and be sure about the result Just saving the project in an older format wonrsquot workproperly at Irsquom using some A2007-specific features
43Renaud | March 9th 2009 at 1008 am
Brilliant code Renaudhellip Very helpfulhellip Thanks Irsquom old at Access but new to the type of coding youused to create the enhanced msgbox I am hoping to use your code to allow users to activate customhelp files from a Help button in some dialogs (doesnrsquot seem to work in standard Access 2007 msgbox-- just fires up the Access help even when custom help file and context are indicated)In my firstattepts to use your box I see that I can now reach the forms help file using F1 from the dialogboxbut it must be possible to use the standard Help buttonCan you help or advise pleaseRegards John
44 John White | May 13th 2009 at 323 pm
45 John White | May 13th 2009 at 715 pm
Regarding my last commenthellip Irsquove added a button in the same way as your btCopy and BtSave andput Sendkeys ldquoF1rdquo into the Click event to fire my custom help
Next issue please I like to set the mouse pointer to jump to default buttons on dialog boxes whichworks with the standard Access 2007 dialogs but not with my new good looking ones Is it possibleto obtain this behaviour on the custom dialog boxRegards John
Thanks for this excelent code fantastic hellip )
46 Uros | June 29th 2009 at 433 pm
Thank you for your hard work and the wonderful message box A quick comment I will be using thisbox to display a warning to my users that I will be terminating their connection so I can performupdates to the back end Irsquod like the Box to AutoClose after a certain period of time regardless ofuser interaction (or more likely non-interaction) I can program this in myself but it may be a usefulfeature to others as well
Thanks againMatthew Pfluger
47 Matthew Pfluger | July 23rd 2009 at 1213 am
Thanks for the great code I added a line to default the dialog caption to the application name if notitle is explicitly set
First few lines of Form_FormDialogShowModal are If m_Title ltgt ldquordquo Then caption = m_Title amp rdquo rdquo Elsecaption = CurrentDbProperties(ldquoAppTitlerdquo) End If
48 kirkrqm | August 8th 2009 at 837 pm
Hi
Tnx 4 your beautiful messagebox I only have one question is it possible to use a vbTab in themessage
With regardsMarianne
49 Marianne Berkhof | October 8th 2009 at 801 pm
Do you have an inputbox variant for this as well
If only i had the time to combine this withhttpwwwdatabasejournalcomfeaturesmsaccessarticlephp3848121Extending-the-InputBox-function-for-MS-Access-Formshtm
Spare time Anybody
50 Lxocram | December 18th 2009 at 457 pm
Sir this is most excellent Thanks for sharing
51 David | February 13th 2010 at 953 pm
I have downloaded your example database Irsquom using Access 2007 but something odd happens Nonof the buttons on the test form seems to activate a trigger In short nothing happens Do you havean explaination for that
52 John | February 16th 2010 at 429 pm
I would like to use vba code to close a message boc programmatically as Matthew Pfluger suggesthe can do in his July 23rd 2009 message Can someone please tell me how to do this
I too am an avid user of your message box replacement
Thanks Bob Robinson
53Bob Robinson | April 16th 2010 at 857 pm
This looks very useful could you please post the source code so those of us not using 2007 can havea go at extracting those parts that will work in earlier versions
Many Thanks
Dave
54 Dave | May 25th 2010 at 1008 pm
[] found the custom message boxes at httpblognkadesigncom2008ms-achellipx-replacement andedited it to fit my needs mdash Background colours borders etc as well as the Images []
55Deleted Image displayed wamphellip | June 17th 2010 at 702 pm
Do you know of any similar utility for MS Excel
Ken
56 Ken Warthen | October 27th 2010 at 215 am
[] really but you can create your own httpblognkadesigncom2008ms-achellip-replacement__________________ (RG for short) aka Allan Bunch MS Access MVP -- WinXP Pro Win7 Pro- acXP[]
57MsgBox Placementamphellip | December 27th 2010 at 345 am
A nice replacement message box that solves the problem (found under Access 2010) of dialog boxesstopping being lsquomodalrsquo before the user presses a button
However the png graphics image files would really be appreciatedhellip
My app has to be capable of running under Access 2003 2007 and 2010 so to keep a similar look andfeel I need to create some bitmaps for the old version
58 Sooz | January 25th 2011 at 242 am
Superb Just came across this it has given my application a ldquofinishedrdquo look One question how do Iforce the application to close after the DialogRichBox appears I checked the example and the checkbox does not fire any code
59 Greg | February 5th 2011 at 417 am
Thank you for your kind words Irsquom glad you found some of these articles useful
Renaud
I have briefly looked over your custom message box concept and like what I see I am curioushowever because unless I am mistaken you have implemented it in Access using standard modulesrather than as a class Is there any particular reason you didnrsquot create a class instead
Glenn
7 Glenn | July 31st 2008 at 613 pm
Hi GlennI think the main reason I didnrsquot use a class was that I wanted a drop-in replacement for thestandard MsgBoxUsing a class would have required creating an instance of it either every time thebox would be used or stored somewhere in a moduleClasses also become an issue as they cannotbe instantiated directly from a library (the way I usually re-use code) and you must end-up having aclass factory in a Module instead
It doesnrsquot mean it canrsquot be done I just donrsquot think it bring anything useful doing it in a Class asopposed to a Module in this case
Maybe Irsquom wrong and there is a better way
In that case let me know -)
8Renaud | July 31st 2008 at 656 pm
Renaud
Thanks for that Your explanation makes perfect sense and I canrsquot think of a compelling reason tosuggest that a class based alternative would be preferable Code libraries are certainly the way to gofor frequently used code
While using a class in this case doesnrsquot appear to offer an advantage over your standard moduleapproach you might be interested to know that there are a couple of ways to include classes in codelibraries such that any application using the library can create instances of the relevant classes
Glenn
9 glenn | August 1st 2008 at 1226 am
This is rather awesome Mind if I take a shot at back-grading it to Access 97
10 Moo | August 1st 2008 at 649 am
GlennI use a simple module that I call ldquoClassFactoryrdquo whose only purpose is to return an instanceof the Classes in the library Not sure if there is a better way
Mooplease be my guest I have been thinking about this recently but since I only have Access2007 testing for older version is a bit of a challenge
Adapting the code to older versions should not be difficult if you stick to plain text You will have toremove references to the ldquoTextFormatrdquo property of the txtMessage textbox as it is new inAccess2007 and used to switch between plain text and rich text
As far as I know the only way to bring rich text to older versions of Access is to use a webbrowser
11Renaud | August 1st 2008 at 957 am
control
If you manage to convert it please send me the updated database so I can host it here for all to find
Renaud
You can do without the module by manipulating the class modulersquos Instancing property The catch isthat the property sheet doesnrsquot allow the setting you need but you can run a single statement in theimmediate window to do the job See this posthttpwwwutteraccesscomforumsshowthreadedphpCat=ampNumber=1441683amppage=ampview=ampsb=5ampo=ampvc=1
Glenn
12 Glenn | August 1st 2008 at 425 pm
Hi Glennthanks for the tip
13Renaud | August 3rd 2008 at 320 pm
Renaud
I gave it a shot and without the RTF it just wouldnrsquot be the same so I chose not to pursue it anyfurther
The Access 2007 version is striking Thanks
Moo
14 Moo | August 6th 2008 at 633 am
Get a compile error when trying to run it ldquoUser defined Type not definedrdquohelliphellipDim f As NewForm_FormDialogHave the same references checked in my Access 2007 VBA Looks great Wouldlike to solve the problem to be able to use it ThanksLarry
15 Larry | August 6th 2008 at 114 pm
This is excellent Irsquove just added it to a new application and it looks far better and I like the ability tocopy the message to the clipboard It is also very good that it is non-blocking ie I can now moreeasily chuck users out of my systems if I want say after a period of inactivityA point that peoplemight find useful is that rather than replace all instances of Msgbox in your code with the wordldquoRichBoxrdquo you can rename the new RichBox function as Msgbox When your code then goes to callthe Msgbox function it then calls the new function ie the old Msgbox gets overridden and the newfunction is called instead
16 Alan Cossey | August 7th 2008 at 402 am
Larry does this happen with the demo or in your applicationHave you renamed the FormDialogif thatrsquos the case make sure to change the line where you get the error to reflect the new nameAnother possibility is security settings if yoursquore getting a security warning when opening the filemake sure you open it from a Trusted location or some functions will be disabled
Alan itrsquos a good point and it could make replacement much easier although I usually prefer to erron the side of caution and avoid overriding base functionality to avoid unintended consequences (andkeep in line with the ldquoelement of least surpriserdquo motto by making things explicit) -)
17Renaud | August 7th 2008 at 207 pm
Thanks for the great object
Out of Stack Space Error
Occurs when modifying DefaultButtonDelayTry modifying the Enable Buttons In field in sample form
Problem occurs in module ldquoDialogrdquo
Reads
Should read
Public Property Let DefaultButtonDelay(delay As Long)
If delay lt 0 Then delay = 0
DefaultButtonDelay = delay
End Property
Public Property Let DefaultButtonDelay(delay As Long)
If delay lt 0 Then delay = 0
m_DefaultButtonDelay = delay
End Property
18 Geoffrey | August 8th 2008 at 1236 am
Compile error happens in my application which is in a Trusted location Didnrsquot rename anything otherthan MsgBox changed to Box as instructed for one of my boxes Am I supposed to renamesomething else The compile error highlights the following VBA codehelliphellipDim f As NewForm_FormDialogLarry
19 Larry | August 8th 2008 at 701 am
Geoffrey good catch I have updated the code Thanks for notifying me
Larry still not sure why yoursquore getting this Could you send me a zip file of your application so I caninvestigate Send it to accessblognkadesign (replacing by and by com)
20Renaud | August 8th 2008 at 1026 am
Larryyou were missing the FormDialog in your application
I have updated the article to list the instructions on how to include the new code into your ownapplication I realised this was missing
21Renaud | August 8th 2008 at 320 pm
Success Enhanced Message Boxes are so much easier to identify when they pop up on the screenThe standard msgboxes are so bland they are almost camoflauged Thank you very muchLarry
22 Larry | August 9th 2008 at 637 am
Your code is way better that what I have written and really works as a replacement to the standardMsgBox function
23Jack Stockton | August 9th 2008 at 656 am
Would like to suggest an enhancementhellipability to specify customer text for two I often have abusiness case where I am displaying a message box asking the user if they want to replace or openthe existing
I got stuckhellip
A friend sent me the A2003 version but it now appears that the RichTextocx is blocked because ofsecurity reasons (apparently they deem it safe in A2007) I registered RICHTX32ocx 60 (SP6) underreferences but the 2003 mdb doesnrsquot compile lsquoacTextFormatHTMLRichTextrsquo is not found -- I found aregistry-patch here httpp2pwroxcomtopicaspTOPIC_ID=10894 -- doesnrsquot work on my pc
There is also a replacement by Stephan Lebans httpwwwlebanscomrichtexthtm -- registeringit didnrsquot help either
Also the png images donrsquot load -- apparently they donrsquot get included on converting -- could youinclude them separately
Any suggestions I really would like to give this replacement a try -- I do see its potential but as Idonrsquot have A2007 I canrsquot run it as such
24Jacques | August 12th 2008 at 657 am
Jacques I can only think of the webbrowser control as a replacementMay be too much overhead but itrsquos worth a tryIrsquove sent you the icons by emailLet me know if yousucceed -)
25Renaud | August 12th 2008 at 351 pm
Thank you Pretty good work
Therersquos one extension Irsquod like to implement or see implemented autowrap for long texts
Therersquos one slight problem with the code as it standshellip The Default Buttons are not set properly TheCode for this looks fine until you notice that the buttons are named in the reverse order to their usebt3 is used as button1 etcetera The rest of the code reflects this the Timer event which sets thedefault does not Easy to change in the timer event just replace each occurence of bt1 with bt3 andbt3 with bt1
Thanks againAndycr
26Andrew Craven Rohm | August 12th 2008 at 610 pm
Whow What a great enhancement for my Access Tools I just tried it and was really happy
Now therersquos a variation I would love to see A modified InputBox Could you do that too
Regards from Germany
Stefan
27 Stefan Reichelt | August 13th 2008 at 1017 pm
Will this tool work with an adp file If so what mods are necessary
28 Joey | September 20th 2008 at 245 am
29Michael Merlin | September 28th 2008 at 627 am
Joey should work perfectly fine in adp
Renaud brilliant work
Thanks for this great enhancement I donrsquot seem to be able to get any of the buttons to be thedefault button any help would be greatly appreciated
Cheers from downunderScott
30 Scott Cordwell | October 30th 2008 at 1122 am
Scott glad you find it usefulRegarding the default button itrsquos not really a feature I wanted to use as one of the points of usingthis enhanced MessageBox is to force users to stop for a second and think about the action theyneed to perform rather than just hitting ENTER or ESC without thinking as is the case with thestandard box
Irsquoll make a note of your suggestion for the next update and probably add it as an option (or a defaultthat can be disabled)
31Renaud | October 30th 2008 at 348 pm
[] Change Color of Text Hi Akilah I ran across this that might help youhttpblognkadesigncom2008ms-achellipx-replacement Bonnie httpwwwdataplus-svccom Akilahwrote gtHi is there a way to change the color of []
32Change Color of Text | keamphellip | January 19th 2009 at 1244 am
Could someone send me an A2003 version of this code This sounds like exactly what I need
33 Dan | January 27th 2009 at 358 am
Hi Renaud -- this is awesome ) Just a quick question -- is there scope to include customising thebuttons So rather than the standard vbYes vbNo etc you can customise them
34 Andy | January 29th 2009 at 302 am
I downloaded your Enhanced MsgBox and it worked great It definitely fit the bill for what I was doinguntil I created an ACCDE version for the users I end up with the error The expression you enteredhas a function name that the database canrsquot find
I have the Enhanced MsgBox getting called during an ldquoon clickrdquo event on a button by using=RichBox([field])
Any ideas
35 Ryan | February 6th 2009 at 910 am
I fixed your vbDefaultButton behavior bug in Form_Timer() can I send you the code
36Henry | February 7th 2009 at 248 am
To Ryan have you tried calling the RichBox from code rather than directly from the Onclick event
37Renaud | February 7th 2009 at 923 am
handler
To Henry yes please send the fix and I will update the code and the samples for everyone My emailis in the footer of the pageThank you
Itrsquos been a long time since Irsquove used Access and so Irsquom getting my feet re-wet Can you refresh me onsome code I would use to call it
38 Ryan | February 7th 2009 at 832 pm
Thanks for this excelent code I think it may be usful to a project I may play with later on
39Andrew | February 18th 2009 at 122 am
Great work based on details and comments I canrsquot possibly use this utility in Access 2002 can I
40 Ash | February 23rd 2009 at 1142 am
Ash thanks Unfortunately there is a major show-stopper if you want to get this to work in pre-2007 versions of Access
older versions donrsquot have rich-edit textboxes so you would probably have to rely on a webbrowsercomponent and that would change a lot
If you are OK with being limited to the plain version of the enhanced MsgBox then your only otherissue should be with displaying transparent images for the icons
41Renaud | February 23rd 2009 at 1238 pm
Have you developed the code for those of us non-Office 2007 users I have Office 2003 and wouldreally like to apply this enhancement
ThanksTom
42 Tom Dessert | March 6th 2009 at 428 am
Tom Dessert no I thought some good soul would try Irsquod be happy if someone did
My main issue is that I donrsquot have any older version of Access so I canrsquot really test theimplementation and be sure about the result Just saving the project in an older format wonrsquot workproperly at Irsquom using some A2007-specific features
43Renaud | March 9th 2009 at 1008 am
Brilliant code Renaudhellip Very helpfulhellip Thanks Irsquom old at Access but new to the type of coding youused to create the enhanced msgbox I am hoping to use your code to allow users to activate customhelp files from a Help button in some dialogs (doesnrsquot seem to work in standard Access 2007 msgbox-- just fires up the Access help even when custom help file and context are indicated)In my firstattepts to use your box I see that I can now reach the forms help file using F1 from the dialogboxbut it must be possible to use the standard Help buttonCan you help or advise pleaseRegards John
44 John White | May 13th 2009 at 323 pm
45 John White | May 13th 2009 at 715 pm
Regarding my last commenthellip Irsquove added a button in the same way as your btCopy and BtSave andput Sendkeys ldquoF1rdquo into the Click event to fire my custom help
Next issue please I like to set the mouse pointer to jump to default buttons on dialog boxes whichworks with the standard Access 2007 dialogs but not with my new good looking ones Is it possibleto obtain this behaviour on the custom dialog boxRegards John
Thanks for this excelent code fantastic hellip )
46 Uros | June 29th 2009 at 433 pm
Thank you for your hard work and the wonderful message box A quick comment I will be using thisbox to display a warning to my users that I will be terminating their connection so I can performupdates to the back end Irsquod like the Box to AutoClose after a certain period of time regardless ofuser interaction (or more likely non-interaction) I can program this in myself but it may be a usefulfeature to others as well
Thanks againMatthew Pfluger
47 Matthew Pfluger | July 23rd 2009 at 1213 am
Thanks for the great code I added a line to default the dialog caption to the application name if notitle is explicitly set
First few lines of Form_FormDialogShowModal are If m_Title ltgt ldquordquo Then caption = m_Title amp rdquo rdquo Elsecaption = CurrentDbProperties(ldquoAppTitlerdquo) End If
48 kirkrqm | August 8th 2009 at 837 pm
Hi
Tnx 4 your beautiful messagebox I only have one question is it possible to use a vbTab in themessage
With regardsMarianne
49 Marianne Berkhof | October 8th 2009 at 801 pm
Do you have an inputbox variant for this as well
If only i had the time to combine this withhttpwwwdatabasejournalcomfeaturesmsaccessarticlephp3848121Extending-the-InputBox-function-for-MS-Access-Formshtm
Spare time Anybody
50 Lxocram | December 18th 2009 at 457 pm
Sir this is most excellent Thanks for sharing
51 David | February 13th 2010 at 953 pm
I have downloaded your example database Irsquom using Access 2007 but something odd happens Nonof the buttons on the test form seems to activate a trigger In short nothing happens Do you havean explaination for that
52 John | February 16th 2010 at 429 pm
I would like to use vba code to close a message boc programmatically as Matthew Pfluger suggesthe can do in his July 23rd 2009 message Can someone please tell me how to do this
I too am an avid user of your message box replacement
Thanks Bob Robinson
53Bob Robinson | April 16th 2010 at 857 pm
This looks very useful could you please post the source code so those of us not using 2007 can havea go at extracting those parts that will work in earlier versions
Many Thanks
Dave
54 Dave | May 25th 2010 at 1008 pm
[] found the custom message boxes at httpblognkadesigncom2008ms-achellipx-replacement andedited it to fit my needs mdash Background colours borders etc as well as the Images []
55Deleted Image displayed wamphellip | June 17th 2010 at 702 pm
Do you know of any similar utility for MS Excel
Ken
56 Ken Warthen | October 27th 2010 at 215 am
[] really but you can create your own httpblognkadesigncom2008ms-achellip-replacement__________________ (RG for short) aka Allan Bunch MS Access MVP -- WinXP Pro Win7 Pro- acXP[]
57MsgBox Placementamphellip | December 27th 2010 at 345 am
A nice replacement message box that solves the problem (found under Access 2010) of dialog boxesstopping being lsquomodalrsquo before the user presses a button
However the png graphics image files would really be appreciatedhellip
My app has to be capable of running under Access 2003 2007 and 2010 so to keep a similar look andfeel I need to create some bitmaps for the old version
58 Sooz | January 25th 2011 at 242 am
Superb Just came across this it has given my application a ldquofinishedrdquo look One question how do Iforce the application to close after the DialogRichBox appears I checked the example and the checkbox does not fire any code
59 Greg | February 5th 2011 at 417 am
control
If you manage to convert it please send me the updated database so I can host it here for all to find
Renaud
You can do without the module by manipulating the class modulersquos Instancing property The catch isthat the property sheet doesnrsquot allow the setting you need but you can run a single statement in theimmediate window to do the job See this posthttpwwwutteraccesscomforumsshowthreadedphpCat=ampNumber=1441683amppage=ampview=ampsb=5ampo=ampvc=1
Glenn
12 Glenn | August 1st 2008 at 425 pm
Hi Glennthanks for the tip
13Renaud | August 3rd 2008 at 320 pm
Renaud
I gave it a shot and without the RTF it just wouldnrsquot be the same so I chose not to pursue it anyfurther
The Access 2007 version is striking Thanks
Moo
14 Moo | August 6th 2008 at 633 am
Get a compile error when trying to run it ldquoUser defined Type not definedrdquohelliphellipDim f As NewForm_FormDialogHave the same references checked in my Access 2007 VBA Looks great Wouldlike to solve the problem to be able to use it ThanksLarry
15 Larry | August 6th 2008 at 114 pm
This is excellent Irsquove just added it to a new application and it looks far better and I like the ability tocopy the message to the clipboard It is also very good that it is non-blocking ie I can now moreeasily chuck users out of my systems if I want say after a period of inactivityA point that peoplemight find useful is that rather than replace all instances of Msgbox in your code with the wordldquoRichBoxrdquo you can rename the new RichBox function as Msgbox When your code then goes to callthe Msgbox function it then calls the new function ie the old Msgbox gets overridden and the newfunction is called instead
16 Alan Cossey | August 7th 2008 at 402 am
Larry does this happen with the demo or in your applicationHave you renamed the FormDialogif thatrsquos the case make sure to change the line where you get the error to reflect the new nameAnother possibility is security settings if yoursquore getting a security warning when opening the filemake sure you open it from a Trusted location or some functions will be disabled
Alan itrsquos a good point and it could make replacement much easier although I usually prefer to erron the side of caution and avoid overriding base functionality to avoid unintended consequences (andkeep in line with the ldquoelement of least surpriserdquo motto by making things explicit) -)
17Renaud | August 7th 2008 at 207 pm
Thanks for the great object
Out of Stack Space Error
Occurs when modifying DefaultButtonDelayTry modifying the Enable Buttons In field in sample form
Problem occurs in module ldquoDialogrdquo
Reads
Should read
Public Property Let DefaultButtonDelay(delay As Long)
If delay lt 0 Then delay = 0
DefaultButtonDelay = delay
End Property
Public Property Let DefaultButtonDelay(delay As Long)
If delay lt 0 Then delay = 0
m_DefaultButtonDelay = delay
End Property
18 Geoffrey | August 8th 2008 at 1236 am
Compile error happens in my application which is in a Trusted location Didnrsquot rename anything otherthan MsgBox changed to Box as instructed for one of my boxes Am I supposed to renamesomething else The compile error highlights the following VBA codehelliphellipDim f As NewForm_FormDialogLarry
19 Larry | August 8th 2008 at 701 am
Geoffrey good catch I have updated the code Thanks for notifying me
Larry still not sure why yoursquore getting this Could you send me a zip file of your application so I caninvestigate Send it to accessblognkadesign (replacing by and by com)
20Renaud | August 8th 2008 at 1026 am
Larryyou were missing the FormDialog in your application
I have updated the article to list the instructions on how to include the new code into your ownapplication I realised this was missing
21Renaud | August 8th 2008 at 320 pm
Success Enhanced Message Boxes are so much easier to identify when they pop up on the screenThe standard msgboxes are so bland they are almost camoflauged Thank you very muchLarry
22 Larry | August 9th 2008 at 637 am
Your code is way better that what I have written and really works as a replacement to the standardMsgBox function
23Jack Stockton | August 9th 2008 at 656 am
Would like to suggest an enhancementhellipability to specify customer text for two I often have abusiness case where I am displaying a message box asking the user if they want to replace or openthe existing
I got stuckhellip
A friend sent me the A2003 version but it now appears that the RichTextocx is blocked because ofsecurity reasons (apparently they deem it safe in A2007) I registered RICHTX32ocx 60 (SP6) underreferences but the 2003 mdb doesnrsquot compile lsquoacTextFormatHTMLRichTextrsquo is not found -- I found aregistry-patch here httpp2pwroxcomtopicaspTOPIC_ID=10894 -- doesnrsquot work on my pc
There is also a replacement by Stephan Lebans httpwwwlebanscomrichtexthtm -- registeringit didnrsquot help either
Also the png images donrsquot load -- apparently they donrsquot get included on converting -- could youinclude them separately
Any suggestions I really would like to give this replacement a try -- I do see its potential but as Idonrsquot have A2007 I canrsquot run it as such
24Jacques | August 12th 2008 at 657 am
Jacques I can only think of the webbrowser control as a replacementMay be too much overhead but itrsquos worth a tryIrsquove sent you the icons by emailLet me know if yousucceed -)
25Renaud | August 12th 2008 at 351 pm
Thank you Pretty good work
Therersquos one extension Irsquod like to implement or see implemented autowrap for long texts
Therersquos one slight problem with the code as it standshellip The Default Buttons are not set properly TheCode for this looks fine until you notice that the buttons are named in the reverse order to their usebt3 is used as button1 etcetera The rest of the code reflects this the Timer event which sets thedefault does not Easy to change in the timer event just replace each occurence of bt1 with bt3 andbt3 with bt1
Thanks againAndycr
26Andrew Craven Rohm | August 12th 2008 at 610 pm
Whow What a great enhancement for my Access Tools I just tried it and was really happy
Now therersquos a variation I would love to see A modified InputBox Could you do that too
Regards from Germany
Stefan
27 Stefan Reichelt | August 13th 2008 at 1017 pm
Will this tool work with an adp file If so what mods are necessary
28 Joey | September 20th 2008 at 245 am
29Michael Merlin | September 28th 2008 at 627 am
Joey should work perfectly fine in adp
Renaud brilliant work
Thanks for this great enhancement I donrsquot seem to be able to get any of the buttons to be thedefault button any help would be greatly appreciated
Cheers from downunderScott
30 Scott Cordwell | October 30th 2008 at 1122 am
Scott glad you find it usefulRegarding the default button itrsquos not really a feature I wanted to use as one of the points of usingthis enhanced MessageBox is to force users to stop for a second and think about the action theyneed to perform rather than just hitting ENTER or ESC without thinking as is the case with thestandard box
Irsquoll make a note of your suggestion for the next update and probably add it as an option (or a defaultthat can be disabled)
31Renaud | October 30th 2008 at 348 pm
[] Change Color of Text Hi Akilah I ran across this that might help youhttpblognkadesigncom2008ms-achellipx-replacement Bonnie httpwwwdataplus-svccom Akilahwrote gtHi is there a way to change the color of []
32Change Color of Text | keamphellip | January 19th 2009 at 1244 am
Could someone send me an A2003 version of this code This sounds like exactly what I need
33 Dan | January 27th 2009 at 358 am
Hi Renaud -- this is awesome ) Just a quick question -- is there scope to include customising thebuttons So rather than the standard vbYes vbNo etc you can customise them
34 Andy | January 29th 2009 at 302 am
I downloaded your Enhanced MsgBox and it worked great It definitely fit the bill for what I was doinguntil I created an ACCDE version for the users I end up with the error The expression you enteredhas a function name that the database canrsquot find
I have the Enhanced MsgBox getting called during an ldquoon clickrdquo event on a button by using=RichBox([field])
Any ideas
35 Ryan | February 6th 2009 at 910 am
I fixed your vbDefaultButton behavior bug in Form_Timer() can I send you the code
36Henry | February 7th 2009 at 248 am
To Ryan have you tried calling the RichBox from code rather than directly from the Onclick event
37Renaud | February 7th 2009 at 923 am
handler
To Henry yes please send the fix and I will update the code and the samples for everyone My emailis in the footer of the pageThank you
Itrsquos been a long time since Irsquove used Access and so Irsquom getting my feet re-wet Can you refresh me onsome code I would use to call it
38 Ryan | February 7th 2009 at 832 pm
Thanks for this excelent code I think it may be usful to a project I may play with later on
39Andrew | February 18th 2009 at 122 am
Great work based on details and comments I canrsquot possibly use this utility in Access 2002 can I
40 Ash | February 23rd 2009 at 1142 am
Ash thanks Unfortunately there is a major show-stopper if you want to get this to work in pre-2007 versions of Access
older versions donrsquot have rich-edit textboxes so you would probably have to rely on a webbrowsercomponent and that would change a lot
If you are OK with being limited to the plain version of the enhanced MsgBox then your only otherissue should be with displaying transparent images for the icons
41Renaud | February 23rd 2009 at 1238 pm
Have you developed the code for those of us non-Office 2007 users I have Office 2003 and wouldreally like to apply this enhancement
ThanksTom
42 Tom Dessert | March 6th 2009 at 428 am
Tom Dessert no I thought some good soul would try Irsquod be happy if someone did
My main issue is that I donrsquot have any older version of Access so I canrsquot really test theimplementation and be sure about the result Just saving the project in an older format wonrsquot workproperly at Irsquom using some A2007-specific features
43Renaud | March 9th 2009 at 1008 am
Brilliant code Renaudhellip Very helpfulhellip Thanks Irsquom old at Access but new to the type of coding youused to create the enhanced msgbox I am hoping to use your code to allow users to activate customhelp files from a Help button in some dialogs (doesnrsquot seem to work in standard Access 2007 msgbox-- just fires up the Access help even when custom help file and context are indicated)In my firstattepts to use your box I see that I can now reach the forms help file using F1 from the dialogboxbut it must be possible to use the standard Help buttonCan you help or advise pleaseRegards John
44 John White | May 13th 2009 at 323 pm
45 John White | May 13th 2009 at 715 pm
Regarding my last commenthellip Irsquove added a button in the same way as your btCopy and BtSave andput Sendkeys ldquoF1rdquo into the Click event to fire my custom help
Next issue please I like to set the mouse pointer to jump to default buttons on dialog boxes whichworks with the standard Access 2007 dialogs but not with my new good looking ones Is it possibleto obtain this behaviour on the custom dialog boxRegards John
Thanks for this excelent code fantastic hellip )
46 Uros | June 29th 2009 at 433 pm
Thank you for your hard work and the wonderful message box A quick comment I will be using thisbox to display a warning to my users that I will be terminating their connection so I can performupdates to the back end Irsquod like the Box to AutoClose after a certain period of time regardless ofuser interaction (or more likely non-interaction) I can program this in myself but it may be a usefulfeature to others as well
Thanks againMatthew Pfluger
47 Matthew Pfluger | July 23rd 2009 at 1213 am
Thanks for the great code I added a line to default the dialog caption to the application name if notitle is explicitly set
First few lines of Form_FormDialogShowModal are If m_Title ltgt ldquordquo Then caption = m_Title amp rdquo rdquo Elsecaption = CurrentDbProperties(ldquoAppTitlerdquo) End If
48 kirkrqm | August 8th 2009 at 837 pm
Hi
Tnx 4 your beautiful messagebox I only have one question is it possible to use a vbTab in themessage
With regardsMarianne
49 Marianne Berkhof | October 8th 2009 at 801 pm
Do you have an inputbox variant for this as well
If only i had the time to combine this withhttpwwwdatabasejournalcomfeaturesmsaccessarticlephp3848121Extending-the-InputBox-function-for-MS-Access-Formshtm
Spare time Anybody
50 Lxocram | December 18th 2009 at 457 pm
Sir this is most excellent Thanks for sharing
51 David | February 13th 2010 at 953 pm
I have downloaded your example database Irsquom using Access 2007 but something odd happens Nonof the buttons on the test form seems to activate a trigger In short nothing happens Do you havean explaination for that
52 John | February 16th 2010 at 429 pm
I would like to use vba code to close a message boc programmatically as Matthew Pfluger suggesthe can do in his July 23rd 2009 message Can someone please tell me how to do this
I too am an avid user of your message box replacement
Thanks Bob Robinson
53Bob Robinson | April 16th 2010 at 857 pm
This looks very useful could you please post the source code so those of us not using 2007 can havea go at extracting those parts that will work in earlier versions
Many Thanks
Dave
54 Dave | May 25th 2010 at 1008 pm
[] found the custom message boxes at httpblognkadesigncom2008ms-achellipx-replacement andedited it to fit my needs mdash Background colours borders etc as well as the Images []
55Deleted Image displayed wamphellip | June 17th 2010 at 702 pm
Do you know of any similar utility for MS Excel
Ken
56 Ken Warthen | October 27th 2010 at 215 am
[] really but you can create your own httpblognkadesigncom2008ms-achellip-replacement__________________ (RG for short) aka Allan Bunch MS Access MVP -- WinXP Pro Win7 Pro- acXP[]
57MsgBox Placementamphellip | December 27th 2010 at 345 am
A nice replacement message box that solves the problem (found under Access 2010) of dialog boxesstopping being lsquomodalrsquo before the user presses a button
However the png graphics image files would really be appreciatedhellip
My app has to be capable of running under Access 2003 2007 and 2010 so to keep a similar look andfeel I need to create some bitmaps for the old version
58 Sooz | January 25th 2011 at 242 am
Superb Just came across this it has given my application a ldquofinishedrdquo look One question how do Iforce the application to close after the DialogRichBox appears I checked the example and the checkbox does not fire any code
59 Greg | February 5th 2011 at 417 am
Thanks for the great object
Out of Stack Space Error
Occurs when modifying DefaultButtonDelayTry modifying the Enable Buttons In field in sample form
Problem occurs in module ldquoDialogrdquo
Reads
Should read
Public Property Let DefaultButtonDelay(delay As Long)
If delay lt 0 Then delay = 0
DefaultButtonDelay = delay
End Property
Public Property Let DefaultButtonDelay(delay As Long)
If delay lt 0 Then delay = 0
m_DefaultButtonDelay = delay
End Property
18 Geoffrey | August 8th 2008 at 1236 am
Compile error happens in my application which is in a Trusted location Didnrsquot rename anything otherthan MsgBox changed to Box as instructed for one of my boxes Am I supposed to renamesomething else The compile error highlights the following VBA codehelliphellipDim f As NewForm_FormDialogLarry
19 Larry | August 8th 2008 at 701 am
Geoffrey good catch I have updated the code Thanks for notifying me
Larry still not sure why yoursquore getting this Could you send me a zip file of your application so I caninvestigate Send it to accessblognkadesign (replacing by and by com)
20Renaud | August 8th 2008 at 1026 am
Larryyou were missing the FormDialog in your application
I have updated the article to list the instructions on how to include the new code into your ownapplication I realised this was missing
21Renaud | August 8th 2008 at 320 pm
Success Enhanced Message Boxes are so much easier to identify when they pop up on the screenThe standard msgboxes are so bland they are almost camoflauged Thank you very muchLarry
22 Larry | August 9th 2008 at 637 am
Your code is way better that what I have written and really works as a replacement to the standardMsgBox function
23Jack Stockton | August 9th 2008 at 656 am
Would like to suggest an enhancementhellipability to specify customer text for two I often have abusiness case where I am displaying a message box asking the user if they want to replace or openthe existing
I got stuckhellip
A friend sent me the A2003 version but it now appears that the RichTextocx is blocked because ofsecurity reasons (apparently they deem it safe in A2007) I registered RICHTX32ocx 60 (SP6) underreferences but the 2003 mdb doesnrsquot compile lsquoacTextFormatHTMLRichTextrsquo is not found -- I found aregistry-patch here httpp2pwroxcomtopicaspTOPIC_ID=10894 -- doesnrsquot work on my pc
There is also a replacement by Stephan Lebans httpwwwlebanscomrichtexthtm -- registeringit didnrsquot help either
Also the png images donrsquot load -- apparently they donrsquot get included on converting -- could youinclude them separately
Any suggestions I really would like to give this replacement a try -- I do see its potential but as Idonrsquot have A2007 I canrsquot run it as such
24Jacques | August 12th 2008 at 657 am
Jacques I can only think of the webbrowser control as a replacementMay be too much overhead but itrsquos worth a tryIrsquove sent you the icons by emailLet me know if yousucceed -)
25Renaud | August 12th 2008 at 351 pm
Thank you Pretty good work
Therersquos one extension Irsquod like to implement or see implemented autowrap for long texts
Therersquos one slight problem with the code as it standshellip The Default Buttons are not set properly TheCode for this looks fine until you notice that the buttons are named in the reverse order to their usebt3 is used as button1 etcetera The rest of the code reflects this the Timer event which sets thedefault does not Easy to change in the timer event just replace each occurence of bt1 with bt3 andbt3 with bt1
Thanks againAndycr
26Andrew Craven Rohm | August 12th 2008 at 610 pm
Whow What a great enhancement for my Access Tools I just tried it and was really happy
Now therersquos a variation I would love to see A modified InputBox Could you do that too
Regards from Germany
Stefan
27 Stefan Reichelt | August 13th 2008 at 1017 pm
Will this tool work with an adp file If so what mods are necessary
28 Joey | September 20th 2008 at 245 am
29Michael Merlin | September 28th 2008 at 627 am
Joey should work perfectly fine in adp
Renaud brilliant work
Thanks for this great enhancement I donrsquot seem to be able to get any of the buttons to be thedefault button any help would be greatly appreciated
Cheers from downunderScott
30 Scott Cordwell | October 30th 2008 at 1122 am
Scott glad you find it usefulRegarding the default button itrsquos not really a feature I wanted to use as one of the points of usingthis enhanced MessageBox is to force users to stop for a second and think about the action theyneed to perform rather than just hitting ENTER or ESC without thinking as is the case with thestandard box
Irsquoll make a note of your suggestion for the next update and probably add it as an option (or a defaultthat can be disabled)
31Renaud | October 30th 2008 at 348 pm
[] Change Color of Text Hi Akilah I ran across this that might help youhttpblognkadesigncom2008ms-achellipx-replacement Bonnie httpwwwdataplus-svccom Akilahwrote gtHi is there a way to change the color of []
32Change Color of Text | keamphellip | January 19th 2009 at 1244 am
Could someone send me an A2003 version of this code This sounds like exactly what I need
33 Dan | January 27th 2009 at 358 am
Hi Renaud -- this is awesome ) Just a quick question -- is there scope to include customising thebuttons So rather than the standard vbYes vbNo etc you can customise them
34 Andy | January 29th 2009 at 302 am
I downloaded your Enhanced MsgBox and it worked great It definitely fit the bill for what I was doinguntil I created an ACCDE version for the users I end up with the error The expression you enteredhas a function name that the database canrsquot find
I have the Enhanced MsgBox getting called during an ldquoon clickrdquo event on a button by using=RichBox([field])
Any ideas
35 Ryan | February 6th 2009 at 910 am
I fixed your vbDefaultButton behavior bug in Form_Timer() can I send you the code
36Henry | February 7th 2009 at 248 am
To Ryan have you tried calling the RichBox from code rather than directly from the Onclick event
37Renaud | February 7th 2009 at 923 am
handler
To Henry yes please send the fix and I will update the code and the samples for everyone My emailis in the footer of the pageThank you
Itrsquos been a long time since Irsquove used Access and so Irsquom getting my feet re-wet Can you refresh me onsome code I would use to call it
38 Ryan | February 7th 2009 at 832 pm
Thanks for this excelent code I think it may be usful to a project I may play with later on
39Andrew | February 18th 2009 at 122 am
Great work based on details and comments I canrsquot possibly use this utility in Access 2002 can I
40 Ash | February 23rd 2009 at 1142 am
Ash thanks Unfortunately there is a major show-stopper if you want to get this to work in pre-2007 versions of Access
older versions donrsquot have rich-edit textboxes so you would probably have to rely on a webbrowsercomponent and that would change a lot
If you are OK with being limited to the plain version of the enhanced MsgBox then your only otherissue should be with displaying transparent images for the icons
41Renaud | February 23rd 2009 at 1238 pm
Have you developed the code for those of us non-Office 2007 users I have Office 2003 and wouldreally like to apply this enhancement
ThanksTom
42 Tom Dessert | March 6th 2009 at 428 am
Tom Dessert no I thought some good soul would try Irsquod be happy if someone did
My main issue is that I donrsquot have any older version of Access so I canrsquot really test theimplementation and be sure about the result Just saving the project in an older format wonrsquot workproperly at Irsquom using some A2007-specific features
43Renaud | March 9th 2009 at 1008 am
Brilliant code Renaudhellip Very helpfulhellip Thanks Irsquom old at Access but new to the type of coding youused to create the enhanced msgbox I am hoping to use your code to allow users to activate customhelp files from a Help button in some dialogs (doesnrsquot seem to work in standard Access 2007 msgbox-- just fires up the Access help even when custom help file and context are indicated)In my firstattepts to use your box I see that I can now reach the forms help file using F1 from the dialogboxbut it must be possible to use the standard Help buttonCan you help or advise pleaseRegards John
44 John White | May 13th 2009 at 323 pm
45 John White | May 13th 2009 at 715 pm
Regarding my last commenthellip Irsquove added a button in the same way as your btCopy and BtSave andput Sendkeys ldquoF1rdquo into the Click event to fire my custom help
Next issue please I like to set the mouse pointer to jump to default buttons on dialog boxes whichworks with the standard Access 2007 dialogs but not with my new good looking ones Is it possibleto obtain this behaviour on the custom dialog boxRegards John
Thanks for this excelent code fantastic hellip )
46 Uros | June 29th 2009 at 433 pm
Thank you for your hard work and the wonderful message box A quick comment I will be using thisbox to display a warning to my users that I will be terminating their connection so I can performupdates to the back end Irsquod like the Box to AutoClose after a certain period of time regardless ofuser interaction (or more likely non-interaction) I can program this in myself but it may be a usefulfeature to others as well
Thanks againMatthew Pfluger
47 Matthew Pfluger | July 23rd 2009 at 1213 am
Thanks for the great code I added a line to default the dialog caption to the application name if notitle is explicitly set
First few lines of Form_FormDialogShowModal are If m_Title ltgt ldquordquo Then caption = m_Title amp rdquo rdquo Elsecaption = CurrentDbProperties(ldquoAppTitlerdquo) End If
48 kirkrqm | August 8th 2009 at 837 pm
Hi
Tnx 4 your beautiful messagebox I only have one question is it possible to use a vbTab in themessage
With regardsMarianne
49 Marianne Berkhof | October 8th 2009 at 801 pm
Do you have an inputbox variant for this as well
If only i had the time to combine this withhttpwwwdatabasejournalcomfeaturesmsaccessarticlephp3848121Extending-the-InputBox-function-for-MS-Access-Formshtm
Spare time Anybody
50 Lxocram | December 18th 2009 at 457 pm
Sir this is most excellent Thanks for sharing
51 David | February 13th 2010 at 953 pm
I have downloaded your example database Irsquom using Access 2007 but something odd happens Nonof the buttons on the test form seems to activate a trigger In short nothing happens Do you havean explaination for that
52 John | February 16th 2010 at 429 pm
I would like to use vba code to close a message boc programmatically as Matthew Pfluger suggesthe can do in his July 23rd 2009 message Can someone please tell me how to do this
I too am an avid user of your message box replacement
Thanks Bob Robinson
53Bob Robinson | April 16th 2010 at 857 pm
This looks very useful could you please post the source code so those of us not using 2007 can havea go at extracting those parts that will work in earlier versions
Many Thanks
Dave
54 Dave | May 25th 2010 at 1008 pm
[] found the custom message boxes at httpblognkadesigncom2008ms-achellipx-replacement andedited it to fit my needs mdash Background colours borders etc as well as the Images []
55Deleted Image displayed wamphellip | June 17th 2010 at 702 pm
Do you know of any similar utility for MS Excel
Ken
56 Ken Warthen | October 27th 2010 at 215 am
[] really but you can create your own httpblognkadesigncom2008ms-achellip-replacement__________________ (RG for short) aka Allan Bunch MS Access MVP -- WinXP Pro Win7 Pro- acXP[]
57MsgBox Placementamphellip | December 27th 2010 at 345 am
A nice replacement message box that solves the problem (found under Access 2010) of dialog boxesstopping being lsquomodalrsquo before the user presses a button
However the png graphics image files would really be appreciatedhellip
My app has to be capable of running under Access 2003 2007 and 2010 so to keep a similar look andfeel I need to create some bitmaps for the old version
58 Sooz | January 25th 2011 at 242 am
Superb Just came across this it has given my application a ldquofinishedrdquo look One question how do Iforce the application to close after the DialogRichBox appears I checked the example and the checkbox does not fire any code
59 Greg | February 5th 2011 at 417 am
Would like to suggest an enhancementhellipability to specify customer text for two I often have abusiness case where I am displaying a message box asking the user if they want to replace or openthe existing
I got stuckhellip
A friend sent me the A2003 version but it now appears that the RichTextocx is blocked because ofsecurity reasons (apparently they deem it safe in A2007) I registered RICHTX32ocx 60 (SP6) underreferences but the 2003 mdb doesnrsquot compile lsquoacTextFormatHTMLRichTextrsquo is not found -- I found aregistry-patch here httpp2pwroxcomtopicaspTOPIC_ID=10894 -- doesnrsquot work on my pc
There is also a replacement by Stephan Lebans httpwwwlebanscomrichtexthtm -- registeringit didnrsquot help either
Also the png images donrsquot load -- apparently they donrsquot get included on converting -- could youinclude them separately
Any suggestions I really would like to give this replacement a try -- I do see its potential but as Idonrsquot have A2007 I canrsquot run it as such
24Jacques | August 12th 2008 at 657 am
Jacques I can only think of the webbrowser control as a replacementMay be too much overhead but itrsquos worth a tryIrsquove sent you the icons by emailLet me know if yousucceed -)
25Renaud | August 12th 2008 at 351 pm
Thank you Pretty good work
Therersquos one extension Irsquod like to implement or see implemented autowrap for long texts
Therersquos one slight problem with the code as it standshellip The Default Buttons are not set properly TheCode for this looks fine until you notice that the buttons are named in the reverse order to their usebt3 is used as button1 etcetera The rest of the code reflects this the Timer event which sets thedefault does not Easy to change in the timer event just replace each occurence of bt1 with bt3 andbt3 with bt1
Thanks againAndycr
26Andrew Craven Rohm | August 12th 2008 at 610 pm
Whow What a great enhancement for my Access Tools I just tried it and was really happy
Now therersquos a variation I would love to see A modified InputBox Could you do that too
Regards from Germany
Stefan
27 Stefan Reichelt | August 13th 2008 at 1017 pm
Will this tool work with an adp file If so what mods are necessary
28 Joey | September 20th 2008 at 245 am
29Michael Merlin | September 28th 2008 at 627 am
Joey should work perfectly fine in adp
Renaud brilliant work
Thanks for this great enhancement I donrsquot seem to be able to get any of the buttons to be thedefault button any help would be greatly appreciated
Cheers from downunderScott
30 Scott Cordwell | October 30th 2008 at 1122 am
Scott glad you find it usefulRegarding the default button itrsquos not really a feature I wanted to use as one of the points of usingthis enhanced MessageBox is to force users to stop for a second and think about the action theyneed to perform rather than just hitting ENTER or ESC without thinking as is the case with thestandard box
Irsquoll make a note of your suggestion for the next update and probably add it as an option (or a defaultthat can be disabled)
31Renaud | October 30th 2008 at 348 pm
[] Change Color of Text Hi Akilah I ran across this that might help youhttpblognkadesigncom2008ms-achellipx-replacement Bonnie httpwwwdataplus-svccom Akilahwrote gtHi is there a way to change the color of []
32Change Color of Text | keamphellip | January 19th 2009 at 1244 am
Could someone send me an A2003 version of this code This sounds like exactly what I need
33 Dan | January 27th 2009 at 358 am
Hi Renaud -- this is awesome ) Just a quick question -- is there scope to include customising thebuttons So rather than the standard vbYes vbNo etc you can customise them
34 Andy | January 29th 2009 at 302 am
I downloaded your Enhanced MsgBox and it worked great It definitely fit the bill for what I was doinguntil I created an ACCDE version for the users I end up with the error The expression you enteredhas a function name that the database canrsquot find
I have the Enhanced MsgBox getting called during an ldquoon clickrdquo event on a button by using=RichBox([field])
Any ideas
35 Ryan | February 6th 2009 at 910 am
I fixed your vbDefaultButton behavior bug in Form_Timer() can I send you the code
36Henry | February 7th 2009 at 248 am
To Ryan have you tried calling the RichBox from code rather than directly from the Onclick event
37Renaud | February 7th 2009 at 923 am
handler
To Henry yes please send the fix and I will update the code and the samples for everyone My emailis in the footer of the pageThank you
Itrsquos been a long time since Irsquove used Access and so Irsquom getting my feet re-wet Can you refresh me onsome code I would use to call it
38 Ryan | February 7th 2009 at 832 pm
Thanks for this excelent code I think it may be usful to a project I may play with later on
39Andrew | February 18th 2009 at 122 am
Great work based on details and comments I canrsquot possibly use this utility in Access 2002 can I
40 Ash | February 23rd 2009 at 1142 am
Ash thanks Unfortunately there is a major show-stopper if you want to get this to work in pre-2007 versions of Access
older versions donrsquot have rich-edit textboxes so you would probably have to rely on a webbrowsercomponent and that would change a lot
If you are OK with being limited to the plain version of the enhanced MsgBox then your only otherissue should be with displaying transparent images for the icons
41Renaud | February 23rd 2009 at 1238 pm
Have you developed the code for those of us non-Office 2007 users I have Office 2003 and wouldreally like to apply this enhancement
ThanksTom
42 Tom Dessert | March 6th 2009 at 428 am
Tom Dessert no I thought some good soul would try Irsquod be happy if someone did
My main issue is that I donrsquot have any older version of Access so I canrsquot really test theimplementation and be sure about the result Just saving the project in an older format wonrsquot workproperly at Irsquom using some A2007-specific features
43Renaud | March 9th 2009 at 1008 am
Brilliant code Renaudhellip Very helpfulhellip Thanks Irsquom old at Access but new to the type of coding youused to create the enhanced msgbox I am hoping to use your code to allow users to activate customhelp files from a Help button in some dialogs (doesnrsquot seem to work in standard Access 2007 msgbox-- just fires up the Access help even when custom help file and context are indicated)In my firstattepts to use your box I see that I can now reach the forms help file using F1 from the dialogboxbut it must be possible to use the standard Help buttonCan you help or advise pleaseRegards John
44 John White | May 13th 2009 at 323 pm
45 John White | May 13th 2009 at 715 pm
Regarding my last commenthellip Irsquove added a button in the same way as your btCopy and BtSave andput Sendkeys ldquoF1rdquo into the Click event to fire my custom help
Next issue please I like to set the mouse pointer to jump to default buttons on dialog boxes whichworks with the standard Access 2007 dialogs but not with my new good looking ones Is it possibleto obtain this behaviour on the custom dialog boxRegards John
Thanks for this excelent code fantastic hellip )
46 Uros | June 29th 2009 at 433 pm
Thank you for your hard work and the wonderful message box A quick comment I will be using thisbox to display a warning to my users that I will be terminating their connection so I can performupdates to the back end Irsquod like the Box to AutoClose after a certain period of time regardless ofuser interaction (or more likely non-interaction) I can program this in myself but it may be a usefulfeature to others as well
Thanks againMatthew Pfluger
47 Matthew Pfluger | July 23rd 2009 at 1213 am
Thanks for the great code I added a line to default the dialog caption to the application name if notitle is explicitly set
First few lines of Form_FormDialogShowModal are If m_Title ltgt ldquordquo Then caption = m_Title amp rdquo rdquo Elsecaption = CurrentDbProperties(ldquoAppTitlerdquo) End If
48 kirkrqm | August 8th 2009 at 837 pm
Hi
Tnx 4 your beautiful messagebox I only have one question is it possible to use a vbTab in themessage
With regardsMarianne
49 Marianne Berkhof | October 8th 2009 at 801 pm
Do you have an inputbox variant for this as well
If only i had the time to combine this withhttpwwwdatabasejournalcomfeaturesmsaccessarticlephp3848121Extending-the-InputBox-function-for-MS-Access-Formshtm
Spare time Anybody
50 Lxocram | December 18th 2009 at 457 pm
Sir this is most excellent Thanks for sharing
51 David | February 13th 2010 at 953 pm
I have downloaded your example database Irsquom using Access 2007 but something odd happens Nonof the buttons on the test form seems to activate a trigger In short nothing happens Do you havean explaination for that
52 John | February 16th 2010 at 429 pm
I would like to use vba code to close a message boc programmatically as Matthew Pfluger suggesthe can do in his July 23rd 2009 message Can someone please tell me how to do this
I too am an avid user of your message box replacement
Thanks Bob Robinson
53Bob Robinson | April 16th 2010 at 857 pm
This looks very useful could you please post the source code so those of us not using 2007 can havea go at extracting those parts that will work in earlier versions
Many Thanks
Dave
54 Dave | May 25th 2010 at 1008 pm
[] found the custom message boxes at httpblognkadesigncom2008ms-achellipx-replacement andedited it to fit my needs mdash Background colours borders etc as well as the Images []
55Deleted Image displayed wamphellip | June 17th 2010 at 702 pm
Do you know of any similar utility for MS Excel
Ken
56 Ken Warthen | October 27th 2010 at 215 am
[] really but you can create your own httpblognkadesigncom2008ms-achellip-replacement__________________ (RG for short) aka Allan Bunch MS Access MVP -- WinXP Pro Win7 Pro- acXP[]
57MsgBox Placementamphellip | December 27th 2010 at 345 am
A nice replacement message box that solves the problem (found under Access 2010) of dialog boxesstopping being lsquomodalrsquo before the user presses a button
However the png graphics image files would really be appreciatedhellip
My app has to be capable of running under Access 2003 2007 and 2010 so to keep a similar look andfeel I need to create some bitmaps for the old version
58 Sooz | January 25th 2011 at 242 am
Superb Just came across this it has given my application a ldquofinishedrdquo look One question how do Iforce the application to close after the DialogRichBox appears I checked the example and the checkbox does not fire any code
59 Greg | February 5th 2011 at 417 am
Joey should work perfectly fine in adp
Renaud brilliant work
Thanks for this great enhancement I donrsquot seem to be able to get any of the buttons to be thedefault button any help would be greatly appreciated
Cheers from downunderScott
30 Scott Cordwell | October 30th 2008 at 1122 am
Scott glad you find it usefulRegarding the default button itrsquos not really a feature I wanted to use as one of the points of usingthis enhanced MessageBox is to force users to stop for a second and think about the action theyneed to perform rather than just hitting ENTER or ESC without thinking as is the case with thestandard box
Irsquoll make a note of your suggestion for the next update and probably add it as an option (or a defaultthat can be disabled)
31Renaud | October 30th 2008 at 348 pm
[] Change Color of Text Hi Akilah I ran across this that might help youhttpblognkadesigncom2008ms-achellipx-replacement Bonnie httpwwwdataplus-svccom Akilahwrote gtHi is there a way to change the color of []
32Change Color of Text | keamphellip | January 19th 2009 at 1244 am
Could someone send me an A2003 version of this code This sounds like exactly what I need
33 Dan | January 27th 2009 at 358 am
Hi Renaud -- this is awesome ) Just a quick question -- is there scope to include customising thebuttons So rather than the standard vbYes vbNo etc you can customise them
34 Andy | January 29th 2009 at 302 am
I downloaded your Enhanced MsgBox and it worked great It definitely fit the bill for what I was doinguntil I created an ACCDE version for the users I end up with the error The expression you enteredhas a function name that the database canrsquot find
I have the Enhanced MsgBox getting called during an ldquoon clickrdquo event on a button by using=RichBox([field])
Any ideas
35 Ryan | February 6th 2009 at 910 am
I fixed your vbDefaultButton behavior bug in Form_Timer() can I send you the code
36Henry | February 7th 2009 at 248 am
To Ryan have you tried calling the RichBox from code rather than directly from the Onclick event
37Renaud | February 7th 2009 at 923 am
handler
To Henry yes please send the fix and I will update the code and the samples for everyone My emailis in the footer of the pageThank you
Itrsquos been a long time since Irsquove used Access and so Irsquom getting my feet re-wet Can you refresh me onsome code I would use to call it
38 Ryan | February 7th 2009 at 832 pm
Thanks for this excelent code I think it may be usful to a project I may play with later on
39Andrew | February 18th 2009 at 122 am
Great work based on details and comments I canrsquot possibly use this utility in Access 2002 can I
40 Ash | February 23rd 2009 at 1142 am
Ash thanks Unfortunately there is a major show-stopper if you want to get this to work in pre-2007 versions of Access
older versions donrsquot have rich-edit textboxes so you would probably have to rely on a webbrowsercomponent and that would change a lot
If you are OK with being limited to the plain version of the enhanced MsgBox then your only otherissue should be with displaying transparent images for the icons
41Renaud | February 23rd 2009 at 1238 pm
Have you developed the code for those of us non-Office 2007 users I have Office 2003 and wouldreally like to apply this enhancement
ThanksTom
42 Tom Dessert | March 6th 2009 at 428 am
Tom Dessert no I thought some good soul would try Irsquod be happy if someone did
My main issue is that I donrsquot have any older version of Access so I canrsquot really test theimplementation and be sure about the result Just saving the project in an older format wonrsquot workproperly at Irsquom using some A2007-specific features
43Renaud | March 9th 2009 at 1008 am
Brilliant code Renaudhellip Very helpfulhellip Thanks Irsquom old at Access but new to the type of coding youused to create the enhanced msgbox I am hoping to use your code to allow users to activate customhelp files from a Help button in some dialogs (doesnrsquot seem to work in standard Access 2007 msgbox-- just fires up the Access help even when custom help file and context are indicated)In my firstattepts to use your box I see that I can now reach the forms help file using F1 from the dialogboxbut it must be possible to use the standard Help buttonCan you help or advise pleaseRegards John
44 John White | May 13th 2009 at 323 pm
45 John White | May 13th 2009 at 715 pm
Regarding my last commenthellip Irsquove added a button in the same way as your btCopy and BtSave andput Sendkeys ldquoF1rdquo into the Click event to fire my custom help
Next issue please I like to set the mouse pointer to jump to default buttons on dialog boxes whichworks with the standard Access 2007 dialogs but not with my new good looking ones Is it possibleto obtain this behaviour on the custom dialog boxRegards John
Thanks for this excelent code fantastic hellip )
46 Uros | June 29th 2009 at 433 pm
Thank you for your hard work and the wonderful message box A quick comment I will be using thisbox to display a warning to my users that I will be terminating their connection so I can performupdates to the back end Irsquod like the Box to AutoClose after a certain period of time regardless ofuser interaction (or more likely non-interaction) I can program this in myself but it may be a usefulfeature to others as well
Thanks againMatthew Pfluger
47 Matthew Pfluger | July 23rd 2009 at 1213 am
Thanks for the great code I added a line to default the dialog caption to the application name if notitle is explicitly set
First few lines of Form_FormDialogShowModal are If m_Title ltgt ldquordquo Then caption = m_Title amp rdquo rdquo Elsecaption = CurrentDbProperties(ldquoAppTitlerdquo) End If
48 kirkrqm | August 8th 2009 at 837 pm
Hi
Tnx 4 your beautiful messagebox I only have one question is it possible to use a vbTab in themessage
With regardsMarianne
49 Marianne Berkhof | October 8th 2009 at 801 pm
Do you have an inputbox variant for this as well
If only i had the time to combine this withhttpwwwdatabasejournalcomfeaturesmsaccessarticlephp3848121Extending-the-InputBox-function-for-MS-Access-Formshtm
Spare time Anybody
50 Lxocram | December 18th 2009 at 457 pm
Sir this is most excellent Thanks for sharing
51 David | February 13th 2010 at 953 pm
I have downloaded your example database Irsquom using Access 2007 but something odd happens Nonof the buttons on the test form seems to activate a trigger In short nothing happens Do you havean explaination for that
52 John | February 16th 2010 at 429 pm
I would like to use vba code to close a message boc programmatically as Matthew Pfluger suggesthe can do in his July 23rd 2009 message Can someone please tell me how to do this
I too am an avid user of your message box replacement
Thanks Bob Robinson
53Bob Robinson | April 16th 2010 at 857 pm
This looks very useful could you please post the source code so those of us not using 2007 can havea go at extracting those parts that will work in earlier versions
Many Thanks
Dave
54 Dave | May 25th 2010 at 1008 pm
[] found the custom message boxes at httpblognkadesigncom2008ms-achellipx-replacement andedited it to fit my needs mdash Background colours borders etc as well as the Images []
55Deleted Image displayed wamphellip | June 17th 2010 at 702 pm
Do you know of any similar utility for MS Excel
Ken
56 Ken Warthen | October 27th 2010 at 215 am
[] really but you can create your own httpblognkadesigncom2008ms-achellip-replacement__________________ (RG for short) aka Allan Bunch MS Access MVP -- WinXP Pro Win7 Pro- acXP[]
57MsgBox Placementamphellip | December 27th 2010 at 345 am
A nice replacement message box that solves the problem (found under Access 2010) of dialog boxesstopping being lsquomodalrsquo before the user presses a button
However the png graphics image files would really be appreciatedhellip
My app has to be capable of running under Access 2003 2007 and 2010 so to keep a similar look andfeel I need to create some bitmaps for the old version
58 Sooz | January 25th 2011 at 242 am
Superb Just came across this it has given my application a ldquofinishedrdquo look One question how do Iforce the application to close after the DialogRichBox appears I checked the example and the checkbox does not fire any code
59 Greg | February 5th 2011 at 417 am
handler
To Henry yes please send the fix and I will update the code and the samples for everyone My emailis in the footer of the pageThank you
Itrsquos been a long time since Irsquove used Access and so Irsquom getting my feet re-wet Can you refresh me onsome code I would use to call it
38 Ryan | February 7th 2009 at 832 pm
Thanks for this excelent code I think it may be usful to a project I may play with later on
39Andrew | February 18th 2009 at 122 am
Great work based on details and comments I canrsquot possibly use this utility in Access 2002 can I
40 Ash | February 23rd 2009 at 1142 am
Ash thanks Unfortunately there is a major show-stopper if you want to get this to work in pre-2007 versions of Access
older versions donrsquot have rich-edit textboxes so you would probably have to rely on a webbrowsercomponent and that would change a lot
If you are OK with being limited to the plain version of the enhanced MsgBox then your only otherissue should be with displaying transparent images for the icons
41Renaud | February 23rd 2009 at 1238 pm
Have you developed the code for those of us non-Office 2007 users I have Office 2003 and wouldreally like to apply this enhancement
ThanksTom
42 Tom Dessert | March 6th 2009 at 428 am
Tom Dessert no I thought some good soul would try Irsquod be happy if someone did
My main issue is that I donrsquot have any older version of Access so I canrsquot really test theimplementation and be sure about the result Just saving the project in an older format wonrsquot workproperly at Irsquom using some A2007-specific features
43Renaud | March 9th 2009 at 1008 am
Brilliant code Renaudhellip Very helpfulhellip Thanks Irsquom old at Access but new to the type of coding youused to create the enhanced msgbox I am hoping to use your code to allow users to activate customhelp files from a Help button in some dialogs (doesnrsquot seem to work in standard Access 2007 msgbox-- just fires up the Access help even when custom help file and context are indicated)In my firstattepts to use your box I see that I can now reach the forms help file using F1 from the dialogboxbut it must be possible to use the standard Help buttonCan you help or advise pleaseRegards John
44 John White | May 13th 2009 at 323 pm
45 John White | May 13th 2009 at 715 pm
Regarding my last commenthellip Irsquove added a button in the same way as your btCopy and BtSave andput Sendkeys ldquoF1rdquo into the Click event to fire my custom help
Next issue please I like to set the mouse pointer to jump to default buttons on dialog boxes whichworks with the standard Access 2007 dialogs but not with my new good looking ones Is it possibleto obtain this behaviour on the custom dialog boxRegards John
Thanks for this excelent code fantastic hellip )
46 Uros | June 29th 2009 at 433 pm
Thank you for your hard work and the wonderful message box A quick comment I will be using thisbox to display a warning to my users that I will be terminating their connection so I can performupdates to the back end Irsquod like the Box to AutoClose after a certain period of time regardless ofuser interaction (or more likely non-interaction) I can program this in myself but it may be a usefulfeature to others as well
Thanks againMatthew Pfluger
47 Matthew Pfluger | July 23rd 2009 at 1213 am
Thanks for the great code I added a line to default the dialog caption to the application name if notitle is explicitly set
First few lines of Form_FormDialogShowModal are If m_Title ltgt ldquordquo Then caption = m_Title amp rdquo rdquo Elsecaption = CurrentDbProperties(ldquoAppTitlerdquo) End If
48 kirkrqm | August 8th 2009 at 837 pm
Hi
Tnx 4 your beautiful messagebox I only have one question is it possible to use a vbTab in themessage
With regardsMarianne
49 Marianne Berkhof | October 8th 2009 at 801 pm
Do you have an inputbox variant for this as well
If only i had the time to combine this withhttpwwwdatabasejournalcomfeaturesmsaccessarticlephp3848121Extending-the-InputBox-function-for-MS-Access-Formshtm
Spare time Anybody
50 Lxocram | December 18th 2009 at 457 pm
Sir this is most excellent Thanks for sharing
51 David | February 13th 2010 at 953 pm
I have downloaded your example database Irsquom using Access 2007 but something odd happens Nonof the buttons on the test form seems to activate a trigger In short nothing happens Do you havean explaination for that
52 John | February 16th 2010 at 429 pm
I would like to use vba code to close a message boc programmatically as Matthew Pfluger suggesthe can do in his July 23rd 2009 message Can someone please tell me how to do this
I too am an avid user of your message box replacement
Thanks Bob Robinson
53Bob Robinson | April 16th 2010 at 857 pm
This looks very useful could you please post the source code so those of us not using 2007 can havea go at extracting those parts that will work in earlier versions
Many Thanks
Dave
54 Dave | May 25th 2010 at 1008 pm
[] found the custom message boxes at httpblognkadesigncom2008ms-achellipx-replacement andedited it to fit my needs mdash Background colours borders etc as well as the Images []
55Deleted Image displayed wamphellip | June 17th 2010 at 702 pm
Do you know of any similar utility for MS Excel
Ken
56 Ken Warthen | October 27th 2010 at 215 am
[] really but you can create your own httpblognkadesigncom2008ms-achellip-replacement__________________ (RG for short) aka Allan Bunch MS Access MVP -- WinXP Pro Win7 Pro- acXP[]
57MsgBox Placementamphellip | December 27th 2010 at 345 am
A nice replacement message box that solves the problem (found under Access 2010) of dialog boxesstopping being lsquomodalrsquo before the user presses a button
However the png graphics image files would really be appreciatedhellip
My app has to be capable of running under Access 2003 2007 and 2010 so to keep a similar look andfeel I need to create some bitmaps for the old version
58 Sooz | January 25th 2011 at 242 am
Superb Just came across this it has given my application a ldquofinishedrdquo look One question how do Iforce the application to close after the DialogRichBox appears I checked the example and the checkbox does not fire any code
59 Greg | February 5th 2011 at 417 am
Regarding my last commenthellip Irsquove added a button in the same way as your btCopy and BtSave andput Sendkeys ldquoF1rdquo into the Click event to fire my custom help
Next issue please I like to set the mouse pointer to jump to default buttons on dialog boxes whichworks with the standard Access 2007 dialogs but not with my new good looking ones Is it possibleto obtain this behaviour on the custom dialog boxRegards John
Thanks for this excelent code fantastic hellip )
46 Uros | June 29th 2009 at 433 pm
Thank you for your hard work and the wonderful message box A quick comment I will be using thisbox to display a warning to my users that I will be terminating their connection so I can performupdates to the back end Irsquod like the Box to AutoClose after a certain period of time regardless ofuser interaction (or more likely non-interaction) I can program this in myself but it may be a usefulfeature to others as well
Thanks againMatthew Pfluger
47 Matthew Pfluger | July 23rd 2009 at 1213 am
Thanks for the great code I added a line to default the dialog caption to the application name if notitle is explicitly set
First few lines of Form_FormDialogShowModal are If m_Title ltgt ldquordquo Then caption = m_Title amp rdquo rdquo Elsecaption = CurrentDbProperties(ldquoAppTitlerdquo) End If
48 kirkrqm | August 8th 2009 at 837 pm
Hi
Tnx 4 your beautiful messagebox I only have one question is it possible to use a vbTab in themessage
With regardsMarianne
49 Marianne Berkhof | October 8th 2009 at 801 pm
Do you have an inputbox variant for this as well
If only i had the time to combine this withhttpwwwdatabasejournalcomfeaturesmsaccessarticlephp3848121Extending-the-InputBox-function-for-MS-Access-Formshtm
Spare time Anybody
50 Lxocram | December 18th 2009 at 457 pm
Sir this is most excellent Thanks for sharing
51 David | February 13th 2010 at 953 pm
I have downloaded your example database Irsquom using Access 2007 but something odd happens Nonof the buttons on the test form seems to activate a trigger In short nothing happens Do you havean explaination for that
52 John | February 16th 2010 at 429 pm
I would like to use vba code to close a message boc programmatically as Matthew Pfluger suggesthe can do in his July 23rd 2009 message Can someone please tell me how to do this
I too am an avid user of your message box replacement
Thanks Bob Robinson
53Bob Robinson | April 16th 2010 at 857 pm
This looks very useful could you please post the source code so those of us not using 2007 can havea go at extracting those parts that will work in earlier versions
Many Thanks
Dave
54 Dave | May 25th 2010 at 1008 pm
[] found the custom message boxes at httpblognkadesigncom2008ms-achellipx-replacement andedited it to fit my needs mdash Background colours borders etc as well as the Images []
55Deleted Image displayed wamphellip | June 17th 2010 at 702 pm
Do you know of any similar utility for MS Excel
Ken
56 Ken Warthen | October 27th 2010 at 215 am
[] really but you can create your own httpblognkadesigncom2008ms-achellip-replacement__________________ (RG for short) aka Allan Bunch MS Access MVP -- WinXP Pro Win7 Pro- acXP[]
57MsgBox Placementamphellip | December 27th 2010 at 345 am
A nice replacement message box that solves the problem (found under Access 2010) of dialog boxesstopping being lsquomodalrsquo before the user presses a button
However the png graphics image files would really be appreciatedhellip
My app has to be capable of running under Access 2003 2007 and 2010 so to keep a similar look andfeel I need to create some bitmaps for the old version
58 Sooz | January 25th 2011 at 242 am
Superb Just came across this it has given my application a ldquofinishedrdquo look One question how do Iforce the application to close after the DialogRichBox appears I checked the example and the checkbox does not fire any code
59 Greg | February 5th 2011 at 417 am
I would like to use vba code to close a message boc programmatically as Matthew Pfluger suggesthe can do in his July 23rd 2009 message Can someone please tell me how to do this
I too am an avid user of your message box replacement
Thanks Bob Robinson
53Bob Robinson | April 16th 2010 at 857 pm
This looks very useful could you please post the source code so those of us not using 2007 can havea go at extracting those parts that will work in earlier versions
Many Thanks
Dave
54 Dave | May 25th 2010 at 1008 pm
[] found the custom message boxes at httpblognkadesigncom2008ms-achellipx-replacement andedited it to fit my needs mdash Background colours borders etc as well as the Images []
55Deleted Image displayed wamphellip | June 17th 2010 at 702 pm
Do you know of any similar utility for MS Excel
Ken
56 Ken Warthen | October 27th 2010 at 215 am
[] really but you can create your own httpblognkadesigncom2008ms-achellip-replacement__________________ (RG for short) aka Allan Bunch MS Access MVP -- WinXP Pro Win7 Pro- acXP[]
57MsgBox Placementamphellip | December 27th 2010 at 345 am
A nice replacement message box that solves the problem (found under Access 2010) of dialog boxesstopping being lsquomodalrsquo before the user presses a button
However the png graphics image files would really be appreciatedhellip
My app has to be capable of running under Access 2003 2007 and 2010 so to keep a similar look andfeel I need to create some bitmaps for the old version
58 Sooz | January 25th 2011 at 242 am
Superb Just came across this it has given my application a ldquofinishedrdquo look One question how do Iforce the application to close after the DialogRichBox appears I checked the example and the checkbox does not fire any code
59 Greg | February 5th 2011 at 417 am