474,039 Members | 2,634 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Replacing the default system message box

Megalog
378 Recognized Expert Contributor
Hey guys-

I've implemented this replacement MsgBox (that I found through the Access Developer blog) in the current database I'm working on. It works great for error handling, or anywhere that I'm calling on a message box in VBA. Basically all you do is install a few modules, one form, and replace 'MsgBox' with the new 'Box' function wherever it's to be used.

But it's not working for native system messages, and I'm wondering if any of you know a way to get Access to default to this new message box for these types of messages as well? The only reason I ask, is this replacement message box allows to copy and paste, or save the error message as a file. It's saving the users all the hassle of writing it down or making screenshots of the errors they sometimes get. I realize this probably isnt possible, but thought I'd throw it out here to let some of you flex your mental muscles.

Thanks!

Mega
Sep 5 '08 #1
3 2552
missinglinq
3,532 Recognized Expert Specialist
I'm guessing that there's not going to be an easy way of doing this! I think the only way you're going to be able to do this is to use the Form_Error event, trap every trappable error you think is likely to be generated, and write custom error messages using the addin. Being able to copy and paste the error code is a very nice feature; I can understand you wanting to use it.

Linq ;0)>
Sep 5 '08 #2
ADezii
8,834 Recognized Expert Expert
The only reason I ask, is this replacement message box allows to copy and paste, or save the error message as a file. It's saving the users all the hassle of writing it down or making screenshots of the errors they sometimes get.
Why not mimic this behavior entirely within Access?
  1. Create a Public Sub-Routine
    Expand|Select|Wrap|Line Numbers
    1. Public Sub LogErrors(dteWhen As Date, lngErrNum As Long, strDesc As String, strUser As String, _
    2.                      strSource As String, strLocation As String)
    3. Dim intNextFreeFile As Integer
    4.  
    5. intNextFreeFile = FreeFile
    6.  
    7. Open CurrentProject.Path & "\Errors.txt" For Append As #intNextFreeFile
    8.  
    9. Print #intNextFreeFile, "Error on:"; Tab(20); dteWhen
    10. Print #intNextFreeFile, "Error Number:"; Tab(19); lngErrNum
    11. Print #intNextFreeFile, "Error Description:"; Tab(20); strDesc
    12. Print #intNextFreeFile, "Source of Error:"; Tab(20); strSource
    13. Print #intNextFreeFile, "Location of Error:"; Tab(20); strLocation
    14. Print #intNextFreeFile, "Current User:"; Tab(20); strUser
    15. Print #intNextFreeFile, "*************************************************************************"
    16.  
    17. Close #intNextFreeFile
    18. End Sub
  2. Place an additional, single line of code, in your Error Handlers that calls the Routine (Line Numbers 12, 11, and 12 below:
    Expand|Select|Wrap|Line Numbers
    1. Private Sub cmdTestErrorLog_Click()
    2. On Error GoTo Err_cmdTestErrorLog_Click
    3.  
    4. 'Test the Sub-Routine
    5. Err.Raise 16
    6.  
    7. Exit_cmdTestErrorLog_Click:
    8.   Exit Sub
    9.  
    10. Err_cmdTestErrorLog_Click:
    11.   MsgBox Err.Description, vbExclamation, "Error in cmdTestErrorLog_Click()"
    12.   Call LogErrors(Now(), Err.Number, Err.Description, CurrentUser(), Err.Source, "cmdTestErrorLog_Click()")
    13.     Resume Exit_cmdTestErrorLog_Click
    14. End Sub
    Expand|Select|Wrap|Line Numbers
    1. Private Sub cmdTestAnotherError_Click()
    2. On Error GoTo Err_cmdTestAnotherError_Click
    3.  
    4. Err.Raise 37
    5.  
    6. Exit_cmdTestAnotherError_Click:
    7.     Exit Sub
    8.  
    9. Err_cmdTestAnotherError_Click:
    10.     MsgBox Err.Description
    11.     Call LogErrors(Now(), Err.Number, Err.Description, CurrentUser(), Err.Source, "cmdTestAnotherError_Click()")
    12.       Resume Exit_cmdTestAnotherError_Click
    13. End Sub
    Expand|Select|Wrap|Line Numbers
    1. Private Sub cboTestAgain_AfterUpdate()
    2. On Error GoTo Err_cboTestAgain_AfterUpdate
    3.  
    4. 'Test the Sub-Routine
    5. Err.Raise 97
    6.  
    7. Exit_cboTestAgain_AfterUpdate:
    8.   Exit Sub
    9.  
    10. Err_cboTestAgain_AfterUpdate:
    11.   MsgBox Err.Description, vbExclamation, "Error in cmdTestErrorLog_Click()"
    12.   Call LogErrors(Now(), Err.Number, Err.Description, CurrentUser(), Err.Source, "cboTestAgain_AfterUpdate()")
    13.     Resume Exit_cboTestAgain_AfterUpdate:
    14. End Sub
  3. Errors.txt in your Current Project Path will not contain a complete History of every Error generated as long as the Routine is called. It will list exactly when the Error occurred, the Error Number and Description, the exact location of the Error, the Source of the Error, and the DB User for which the Error happened.
  4. Sample OUTPUT listed below:
    Expand|Select|Wrap|Line Numbers
    1. Error on:          9/5/2008 7:43:17 PM 
    2. Error Number:      16 
    3. Error Description: Expression too complex
    4. Source of Error:   Northwind
    5. Location of Error: cmdTestErrorLog_Click()
    6. Current User:      Admin
    7. *************************************************************************
    8. Error on:          9/5/2008 7:45:45 PM 
    9. Error Number:      37 
    10. Error Description: Application-defined or object-defined error
    11. Source of Error:   Northwind
    12. Location of Error: cmdTestAnotherError_Click()
    13. Current User:      Admin
    14. *************************************************************************
    15. Error on:          9/5/2008 7:50:31 PM 
    16. Error Number:      97 
    17. Error Description: Can not call friend function on object which is not an instance of defining class
    18. Source of Error:   Northwind
    19. Location of Error: cboTestAgain_AfterUpdate()
    20. Current User:      Admin
    21. *************************************************************************
Sep 6 '08 #3
Megalog
378 Recognized Expert Contributor
Thanks for the replies guys, and the code too Adezii. I'm going to work that into this db today. This still doesnt trap the native messages that are occuring outside of the error handling that I already have in place, but it will help take care of the error reporting that some of the lazy users arent doing!
Sep 6 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

13
15340
by: yaipa | last post by:
What would be the common sense way of finding a binary pattern in a ..bin file, say some 200 bytes, and replacing it with an updated pattern of the same length at the same offset? Also, the pattern can occur on any byte boundary in the file, so chunking through the code at 16 bytes a frame maybe a problem. The file itself isn't so large, maybe 32 kbytes is all and the need for speed is not so great, but the need for accuracy in the...
3
2151
by: Muntz | last post by:
Hi - we are MSDN Enterprise subscribers, our no-spam address is munter@computershare.com We are currently trying to replace a SoapToolkit web-service with a .NET WebMethod implementation, but can't seem to get the WSDL to line up properly. I consulted the migration document: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/migrsoapwebserv.asp I then used wsdl.exe to create an abstract class definition...
7
21727
by: VMI | last post by:
If I have the string "Héllo", how can I replace char (é) with an 'e'? I cannot use the String.Replace() fuction. It has to be by replacing one char with another. Thanks.
12
2623
by: anonymous | last post by:
Hello, I need to replace this char  with another char. However I am not able to acieve this. I tried this but it doesnt work: str = str.Replace(chr(asc(194)), "") Can somebody help ?
7
2618
by: Ryan Taylor | last post by:
Hi. I have some code that dynamically generates a PDF and spits this content directly to the web browser. I use HTMLDoc to create the Pdf's from html. So the user can click on a button "Print PDF" and the current page magically becomes a PDF file. This worked great until we moved the site to https. Now, when the button is clicked, I get a warning that This page contains both secure and nonsecure items. Do you want to display the...
12
5970
by: Adam J. Schaff | last post by:
I am writing a quick program to edit a binary file that contains file paths (amongst other things). If I look at the files in notepad, they look like: <gibberish>file//g:\pathtofile1<gibberish>file//g:\pathtofile2<gibberish> etc. I want to remove the "g:\" from the file paths. I wrote a console app that successfully reads the file and writes a duplicate of it, but fails for some reason to do the "replacing" of the "g:\". The code...
2
4219
by: Alain | last post by:
Hi, I am working on a project where I need to convert international characters with acii values. Like André -> andre and Björn -> bjorn. How can I do this without replacing every single character? lastname = lastname.Replace("â", "a"); lastname = lastname.Replace("é", "e"); lastname = lastname.Replace("ö", "o");
14
1817
by: Josh Baltzell | last post by:
I am having a lot more trouble with this than I thought I would. Here is what I want to do in pseudocode. Open c:\some.pdf Replace "Replace this" with "Replaced!" Save c:\some_edited.pdf I can do this in notepad and it works fine, but when I start getting in to reading the files I think it has some encoding problem. I tried saving the file with every encoding option. When I open a PDF in the
10
1959
by: Scott M. | last post by:
I've seen many posts and ready articles discussing how changing the membership & roles "provider" in VS .NET is easy, but have yet to see instructions on how to do it. If I already have SQL Server 2000 on a machine and didn't install SQL Server 2005 Express with my VS .NET installation, how do I set up my existing SQL 2000 server to be the membership & roles provider for ASP .NET?
0
10535
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
12127
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
11987
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
11134
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8686
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6645
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
4935
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3954
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.