|
-
Apr 18th, 2008, 11:08 AM
#1
Thread Starter
Lively Member
[RESOLVED] Help: What is the easiest way to have Error write to an error log.txt
Hi ALL
I am a beginner in this..
I found the easiest to trap an error is just create a message box
ErrTrap:
MsgBox "Error trying to update the current record: " & Err.Description, vbCritical + vbOKOnly, App.Title
Now I want it to write this error to a file also ..
Could some one help me create a simple function that will write the message to an error.txt
it could be as primitive and simple ..
please help
thank you
-
Apr 18th, 2008, 11:32 AM
#2
Re: Help: What is the easiest way to have Error write to an error log.txt
 Originally Posted by ndondo
Hi ALL
I am a beginner in this..
I found the easiest to trap an error is just create a message box
ErrTrap:
MsgBox "Error trying to update the current record: " & Err.Description, vbCritical + vbOKOnly, App.Title
Now I want it to write this error to a file also ..
Could some one help me create a simple function that will write the message to an error.txt
it could be as primitive and simple ..
please help
thank you 
Declare a string variable and store the above message to that
If you search the forum, you will see plenty of example on how to write to a text file. simply write the variable's data to text...
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Apr 18th, 2008, 11:45 AM
#3
Re: Help: What is the easiest way to have Error write to an error log.txt
Code:
Private Sub Command1_Click()
On Error GoTo ErrTrap
'way cool code
Exit Sub
ErrTrap:
Open "c:\errorlog.txt" For Append As #1
Print #1, "An Error has occurred on " & Format(Now, "mm/dd/yyyy") & " in Command1_Click" & vbCrLf & vbCrLf
Print #1, "The error is: " & Err.Number & " " & Err.Description
Close #1
End Sub
-
Apr 18th, 2008, 01:27 PM
#4
Thread Starter
Lively Member
Re: Help: What is the easiest way to have Error write to an error log.txt
Thank you! 
I will try it and post back!
I appreciate it very much
-
Apr 18th, 2008, 01:48 PM
#5
Re: Help: What is the easiest way to have Error write to an error log.txt
You can add pretty much anything you want.
I write my errors back to an errorlog DB table which includes the username, machine name, date/time of the error, where in the program the error occured and what the error number and error description is.
I built a special Admin Only screen which will display all errors in the table, and when you click on one, it will give the details as logged. In addition, the table also includes a field for notes and resolutions so that anytime anyone with permissions to the errorslog table (like my boss ) can go in a take a look at what has been going on, and what has been done about it.
-
Apr 18th, 2008, 05:24 PM
#6
Thread Starter
Lively Member
Re: Help: What is the easiest way to have Error write to an error log.txt
This Solved my Problem! 
Thank you very much sir
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|