Logging for debug purposes

mcdhappy80

Registered User.
Local time
Today, 15:29
Joined
Jun 22, 2009
Messages
347
I've read somewhere that Logging can be turned on for debug purposes.
Can anyone explain how to do this?
Does it need to be turned for every object?
Where will the log files be saved, how to specify the destination folder?
And all the interesting stuff You remember on this matter.

Thank You.
 
Dang, it would be SWEET if that were built in to Access/VBA. DBMSs (SQL Server, MySQL, and Oracle) have some logging but not enough to help out very much when developing.

Alas, you'll need to roll your own.
 
I've read "Wiley's Access Bible 2007 with CD" and in Chapter 28, page 906 I've found part with this name "Adding Logging To Applications". In there is a sample code of a Log Error procedure, which should be called from a function (that is suspected to cause error) and stores some information in table tblErrorLog. I'll give sample codes here and then tell you what is the problem:

Log Error Function:

Code:
Function LogError (ProcName As String, _
  ErrNum As Integer, ErrDescription) As Integer
  Dim MyDB As DAO.Database
  Dim tblErr As Table
  Set MyDB = CurrentDB()
  Set tblErr = MyDB.OpenTable(“tblErrorLog”)
  tblErr.AddNew
  tblErr(“TimeDateStamp”) = Now
  tblErr(“ErrorNumber”) = ErrNum
  tblErr(“ErrorDescription”) = ErrDescription
  tblErr(“ProcedureName”) = ProcName
  ‘ The following may be null if no form
  ‘ or control is currently active.
  tblErr(“FormName”) = Screen.ActiveForm.FormName
  tblErr(“ControlName”) = Screen.ActiveControl.ControlName
  tblErr.Update
  tblErr.Close
  End Function
Code that triggers error:

Code:
Private Sub Form_Current()
On Error GoTo MyErrorHandler
<my code goes here>
MyErrorHandler:
LogError "btnRepResenje1_Click()", Err.Number, Err.Description
Resume
End Sub
Here's the problem. When I start form I'm getting this error message:

Compiler Error:
Function or interface marked as restricted, or the function uses Automation type not supported in Visual Basic.
The line that causes error is this (the bolded part):

Set tblErr = MyDB.OpenTable(“tblErrorLog”)
What is wrong here. Can this be solved, and how?

Thank You.
 
I wonder 2 things:
1. Is there a table named "tblErrorLog" in your system.
2. Are the quote marks around "tblErrorLog" on the line in question true VB quote marks or were they pasted in from a program that changed them to a different, non-VB, quote mark. Try deleting the quote marks and typing " in their place. If this "fixes" your problem, I would expect you would see it again 2 lines later.

HTH.
 
I wonder 2 things:
1. Is there a table named "tblErrorLog" in your system.
2. Are the quote marks around "tblErrorLog" on the line in question true VB quote marks or were they pasted in from a program that changed them to a different, non-VB, quote mark. Try deleting the quote marks and typing " in their place. If this "fixes" your problem, I would expect you would see it again 2 lines later.

HTH.

Table tblErrorLog exists in my database, and it has several fields for storing, time, error number, error description, which procedure, form, and control caused it.

Could You please post the line of code that is on Your mind?
All of this code is manually typed not pasted from anywhere.
 
Set tblErr = MyDB.OpenTable(“tblErrorLog”)

Needs to be changed to

Set tblErr = MyDB.OpenRecordset(“tblErrorLog”)


David
 

Users who are viewing this thread

Back
Top Bottom