Printing error messages (1 Viewer)

Chris RR

Registered User.
Local time
Yesterday, 20:11
Joined
Mar 2, 2000
Messages
354
I am automating an Access 2000 system and would like to know if there's a way to redirect error messages to a printer (or a file???)

Right now I want to have message boxes when I hit an error. But once this is running unattended, I'd like to log the errors (to a file or to print) and shut down Access. The shutdown is no problem; just need to raise the visibility of the errors.
 

AlanS

Registered User.
Local time
Yesterday, 21:11
Joined
Mar 23, 2001
Messages
292
Set up a table for your error messages. Where you now have code to display the error message in a MsgBox, replace that with DAO code to open the table, create and add a new record, and close it. If you wish to print one or more error table records, set up a report based on that table, and use the DoCmd.OpenReport method - if you want to limit the report to only one or some records, include an appropriate Filter or Where Clause argument with the OpenReport method.
 

Chris RR

Registered User.
Local time
Yesterday, 20:11
Joined
Mar 2, 2000
Messages
354
I can see where that would work in some circumstances. What I'd really like here is to find some way of directing a message to the standard sysout, so that the error would be visible to the computer room operator (who is not in front of this particular machine.)

By the way, email isn't an option. The job that I'm trying to run sends email, but if the error is because it can't send out that email, then there's no point in using the same process for errors, now is there?
 

Talismanic

Registered User.
Local time
Today, 02:11
Joined
May 25, 2000
Messages
377
Chris, if the database and the computer that needs to get the message are NT you could use the net send command. I threw this together real quick so that you could have an example of what I am talking about.

Dim strCompName as String
Dim strMessage as String
Dim strNetSend as String

strCompName = "ComputerName " ' Use name of computer that gets message.
strMessage = "This seems to be working!" ' Message to send.
strNetSend = strCompName & strMessage ' Puts it all together.

Call Shell("net send " & strNetSend, 1) ' Run the net send command.

All it lacks is the error trapping but I would think it would work for what you are trying to do. Please let me know if it does.


[This message has been edited by Talismanic (edited 08-16-2001).]
 

Chris RR

Registered User.
Local time
Yesterday, 20:11
Joined
Mar 2, 2000
Messages
354
Thanks. It works well (I'm running Windows 2000; "same difference", as my Mom would say...)

[This message has been edited by Chris RR (edited 08-17-2001).]
 

Talismanic

Registered User.
Local time
Today, 02:11
Joined
May 25, 2000
Messages
377
Glad to hear that it worked out for you, you can also use Net Send to send messages to groups, for instance the Administrators group.

Have you built the error trapping into it yet? If so, and you wouldn't mind, I would like to take a peek at your code.
 

Chris RR

Registered User.
Local time
Yesterday, 20:11
Joined
Mar 2, 2000
Messages
354
I haven't done much yet with the error trapping. I put the display code into a separate module, then build the message like this:
strMessage = "Automated System Error: " ' Message to send.
strMessage = strMessage & Err.Number & " " & Err.Description

Now I have another programmer here who will need to do this same message send. BUT...he won't use VBA at all (for religious reasons, maybe, I don't know, I keep trying to convert him) so that's the next step.
 

Users who are viewing this thread

Top Bottom