Curious Question

  • Thread starter Thread starter James
  • Start date Start date
J

James

Hello I have been given the following code and I was
wondering if it will just keep adding to the .LOG file for
the errors it picks up?? and will the error log just stay
where it is? so for example if I close the database
the .LOG file stays where it is???

Here is the code:

-----------------------------------------------------------
Public Function ErrorLog(ObjName As String, routineName As
String)
Dim db As Database

Set db = CurrentDb

Open "I:\Error.log" For Append As #1

Print #1, Format(Now, "mm/dd/yyyy, hh:nn:ss") & ", " &
db.Name & _
" Unauthorized Access occured in " & ObjName & ", " &
routineName & _
", " & " User: " & GetUsrName() & ", Error#: " &
Err.Number & ", " & Err.Description

Close #1
 
James,

The line of code:

Open "I:\Error.log" For Append As #1

indicates that the file will have records added to it each time it is
opened. If the file does not exist, it will be created the next time the
code is run. When the code completes (hopefully with a Close statement),
the file will remain in its location on the stated drive.

For more info on this, use VBA Help and in the Answer Wizard, enter "open
statement" (without quotes).

hth,
 
Back
Top