Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Apr 2002
    Location
    Evansville, Indiana, USA
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Error Logging (2000)

    I would like for errors to be logged to a text file when they happen. What code should I add to the on err event of my button to log this data to a text file?
    Thanks,

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Error Logging (2000)

    You can use code like this:
    <code>
    Private Sub cmdSomething_Click()
    ...
    ...
    Exit Sub

    ErrHandler:
    Const strLogfile = "C:Err.log"
    Dim f As Integer
    f = FreeFile
    Open strLogfile For Append As #f
    Print #f, "Error " & Err & ": " & Err.Description
    Close #f
    End Sub
    </code>
    You can change the line that is written to the text file, and you can display a message box in addition to writing to the log file, etc.

  3. #3
    2 Star Lounger
    Join Date
    Apr 2002
    Location
    Evansville, Indiana, USA
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Error Logging (2000)

    thanks hans... thats what i needed.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •