how to get Caption of current control for errmodule

vinzz

Registered User.
Local time
Today, 04:39
Joined
Apr 24, 2008
Messages
47
hi,

i'm trying to make an errmodule so i can see in a table when a user makes a fault other then 0.
i have this as err in each function:
Code:
Call ErrorDB(me.caption)
and a module:
Code:
Public Function ErrorDB(errctl As String)
Dim db As Database
Dim LSQL As String
Dim errnum As String
Dim errdesc As String
errnum = Err.Number
errdesc = Err.Description
If Err.Number <> 0 Then
Set db = CurrentDb()
LSQL = "insert into tblerrors (Gebruiker,errnummer,erromschrijving,erronForm,erronctrl) values ('" & NaamGebruiker & "','" & errnum & "','" & errdesc & "','" & CurrentObjectName & "','" & errctl & "')"
db.Execute LSQL, dbFailOnError
    On Error GoTo 0
Set db = Nothing
MsgBox errdesc, vbCritical, errnum
End If
End Function

i'm trying to get the current control name (caption) to set in the tablecolumn "erronctrl". I tried alot in the function caller like:
Code:
Call ErrorDB(me.caption)
Code:
Call ErrorDB(ctl.caption)
Code:
Call ErrorDB(ctl.tag)
Code:
Call ErrorDB(ctl.controls.caption)
But without any succes. Does anyone knows how to get the caption name (or function name) where the error occured.

thanks in advance :P

greetz
Vincent B.
 

yeah, it's the same system as mine, only mine is better and simple :P, i just have to change one thing and i have exact the same function.

If i change this:

Code:
Call ErrorDB("some err text here for current procedure")

I want a function that automatically get the caption name and place it in the database in the column erronctrl.
But if this isn't possible, i will use this function like above (mine works with the parameter above
 
Last edited:
active control is probably as simple as

myname = screen.activecontrol.name
 
i'll check it out and let you know if it works
 

Users who are viewing this thread

Back
Top Bottom