function help needed

J

JohnE

I am trying to put together a function for error logging into an sql2005
table. The function will be in the front end of the application. Below is
what I have so far that is getting me frustrated. Originally, I had a stored
procedure to with the insert which when executed worked fine. Most of it is
below the execute line. I am trying to move it into the front end. As of
now, I'm not even sure if I'm on the right path or not. The INSERT INTO is
the table and the field. The ErrorDate is a datetime and ApplicationSignon
is a bit. The remaining fields are varchar.

Function ErrorLog(module As String, event_procedure As String, Optional
application_signon As Boolean)

Dim error_date As Date
Dim user_name As String
Dim computer_name As String
Dim Form As String
Dim control As String

error_date = Now()
user_name = gUsername
computer_name = Environ("ComputerName")
error_number = err.Number
error_description = err.Description
'module =
Form = Screen.ActiveForm.Name
control = Screen.ActiveControl
'event_procedure =
'application_signon =

Call CurrentProject.Connection.Execute_
INSERT INTO ErrorLog
(ErrorDate,
UserName,
ComputerName,
ErrorNumber,
ErrorDescription,
Module,
Form,
Control,
EventProcedure,
ApplicationSignon)

Values
(GetDate(),
@username,
@computername,
@errornumber,
@errordescription,
@module,
@form,
@control,
@eventprocedure,
@applicationsignon)



End Function

I ask if someone can look at this and undo the jumbled mess.

Thanks...John
 
D

Dorian

All IO to database should be in back-end! make it either a stored proc or a
function. Pass the values as parameters.
Why try to put in front-end?
Your syntax is written for a stored procedure, the @--- prefixes will not
work in the front end.
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top