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
3 2552
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)> 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? - Create a Public Sub-Routine
- Public Sub LogErrors(dteWhen As Date, lngErrNum As Long, strDesc As String, strUser As String, _
-
strSource As String, strLocation As String)
-
Dim intNextFreeFile As Integer
-
-
intNextFreeFile = FreeFile
-
-
Open CurrentProject.Path & "\Errors.txt" For Append As #intNextFreeFile
-
-
Print #intNextFreeFile, "Error on:"; Tab(20); dteWhen
-
Print #intNextFreeFile, "Error Number:"; Tab(19); lngErrNum
-
Print #intNextFreeFile, "Error Description:"; Tab(20); strDesc
-
Print #intNextFreeFile, "Source of Error:"; Tab(20); strSource
-
Print #intNextFreeFile, "Location of Error:"; Tab(20); strLocation
-
Print #intNextFreeFile, "Current User:"; Tab(20); strUser
-
Print #intNextFreeFile, "*************************************************************************"
-
-
Close #intNextFreeFile
-
End Sub
- Place an additional, single line of code, in your Error Handlers that calls the Routine (Line Numbers 12, 11, and 12 below:
- Private Sub cmdTestErrorLog_Click()
-
On Error GoTo Err_cmdTestErrorLog_Click
-
-
'Test the Sub-Routine
-
Err.Raise 16
-
-
Exit_cmdTestErrorLog_Click:
-
Exit Sub
-
-
Err_cmdTestErrorLog_Click:
-
MsgBox Err.Description, vbExclamation, "Error in cmdTestErrorLog_Click()"
-
Call LogErrors(Now(), Err.Number, Err.Description, CurrentUser(), Err.Source, "cmdTestErrorLog_Click()")
-
Resume Exit_cmdTestErrorLog_Click
-
End Sub
- Private Sub cmdTestAnotherError_Click()
-
On Error GoTo Err_cmdTestAnotherError_Click
-
-
Err.Raise 37
-
-
Exit_cmdTestAnotherError_Click:
-
Exit Sub
-
-
Err_cmdTestAnotherError_Click:
-
MsgBox Err.Description
-
Call LogErrors(Now(), Err.Number, Err.Description, CurrentUser(), Err.Source, "cmdTestAnotherError_Click()")
-
Resume Exit_cmdTestAnotherError_Click
-
End Sub
- Private Sub cboTestAgain_AfterUpdate()
-
On Error GoTo Err_cboTestAgain_AfterUpdate
-
-
'Test the Sub-Routine
-
Err.Raise 97
-
-
Exit_cboTestAgain_AfterUpdate:
-
Exit Sub
-
-
Err_cboTestAgain_AfterUpdate:
-
MsgBox Err.Description, vbExclamation, "Error in cmdTestErrorLog_Click()"
-
Call LogErrors(Now(), Err.Number, Err.Description, CurrentUser(), Err.Source, "cboTestAgain_AfterUpdate()")
-
Resume Exit_cboTestAgain_AfterUpdate:
-
End Sub
- 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.
- Sample OUTPUT listed below:
- Error on: 9/5/2008 7:43:17 PM
-
Error Number: 16
-
Error Description: Expression too complex
-
Source of Error: Northwind
-
Location of Error: cmdTestErrorLog_Click()
-
Current User: Admin
-
*************************************************************************
-
Error on: 9/5/2008 7:45:45 PM
-
Error Number: 37
-
Error Description: Application-defined or object-defined error
-
Source of Error: Northwind
-
Location of Error: cmdTestAnotherError_Click()
-
Current User: Admin
-
*************************************************************************
-
Error on: 9/5/2008 7:50:31 PM
-
Error Number: 97
-
Error Description: Can not call friend function on object which is not an instance of defining class
-
Source of Error: Northwind
-
Location of Error: cboTestAgain_AfterUpdate()
-
Current User: Admin
-
*************************************************************************
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!
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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...
|
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.
|
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 ?
|
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...
| |
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...
|
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");
|
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
|
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?
|
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...
|
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...
| |
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,...
|
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...
|
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...
|
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();...
|
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...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |