Kryst51
Singin' in the Hou. Rain
- Local time
- Yesterday, 22:25
- Joined
- Jun 29, 2009
- Messages
- 1,898
Hi All,
I just moved my tables to an SQL server, and linked my tables to my Access 2010 front end. In this db, I have a table for error logs, and used code I found on Allen Browne's site to log errors. It worked fine when the tables were in Access, but I get an error now that the tables are in SQL.
I fixed the original error, shown in Green below. but now I get the following error:
This is my first go with an SQL backend, so I have absolutely no idea what I am doing, so I certainly don't know what I am doing wrong. Googling the error seems to come up with a ton of explanations that I either don't understand or that I don't think apply to my scenario.
I just moved my tables to an SQL server, and linked my tables to my Access 2010 front end. In this db, I have a table for error logs, and used code I found on Allen Browne's site to log errors. It worked fine when the tables were in Access, but I get an error now that the tables are in SQL.
I fixed the original error, shown in Green below. but now I get the following error:
Error 3001 Invalid Argument
This is my first go with an SQL backend, so I have absolutely no idea what I am doing, so I certainly don't know what I am doing wrong. Googling the error seems to come up with a ton of explanations that I either don't understand or that I don't think apply to my scenario.
Code:
Function ErrorLog(ByVal ErrorNum As Long, ByVal ErrorDes As String, _
strCallingProc As String, ModName As String, Optional bShowUser As Boolean = False) _
As Boolean
'--------------------------------------------
' Procedure : ErrorLog
' Author : Allen Browne, [EMAIL="allen@allenbrowne.com"]allen@allenbrowne.com[/EMAIL]
' Date : 8/3/2010
' Purpose : Generic error handler.
' Arguments : ErrorNum - value of Err.Number
' ErrorDes : value of Err.Description
' strCallingProc: name of sub|function that
' generated the error.
' bShowUser : optional boolean: If False,
' suppresses display.
'
'Logs errors to table "tblErrorLogID".
'--------------------------------------------
On Error GoTo Err_ErrorLog
' Purpose: Generic error handler.
' Logs errors to table "tblDatabaseErrorLog".
' Arguments: ErrorNum - value of Err.Number
' ErrorDes - value of Err.Description
' strCallingProc - name of sub|function that generated the error.
' bShowUser - optional boolean: If False, suppresses display.
' Author: Allen Browne, [EMAIL="allen@allenbrowne.com"]allen@allenbrowne.com[/EMAIL]
Dim strMsg As String ' String for display in MsgBox
Dim rst As DAO.Recordset ' The tblErrorLogID table
Select Case ErrorNum
'Case 0
'Debug.Print strCallingProc & " called error 0."
'Case 2501 ' Cancelled
'Do nothing.
Case 3314, 2101, 2115 ' Can't save.
bShowUser = True
If bShowUser Then
strMsg = "Record cannot be saved at this time." & vbCrLf & _
"Complete the entry, or press <Esc> to undo."
MsgBox strMsg, vbExclamation, strCallingProc
End If
Case Else
If bShowUser Then
strMsg = "Error " & ErrorNum & ": " & ErrorDes
MsgBox strMsg, vbExclamation, strCallingProc
End If
[COLOR=green][B]'Here is where I added the change[/B][/COLOR]
Set rst = CurrentDb.OpenRecordset("tblErrorLogID", , dbAppendOnly[COLOR=green][B], dbSeeChanges)[/B][/COLOR]
rst.AddNew
rst![ErrorNumber] = ErrorNum
rst![ErrorDescription] = ErrorDes
rst![ErrorDateTime] = Now()
rst![ErrorProcedure] = strCallingProc
rst![ShowUser] = bShowUser
rst![ModuleName] = ModName
rst.Update
rst.Close
ErrorLog = True
End Select
Exit_ErrorLog:
Set rst = Nothing
Exit Function
Err_ErrorLog:
strMsg = "An unexpected situation arose in your program." & vbCrLf & _
"Please write down the following details:" & vbCrLf & vbCrLf & _
"Calling Proc: " & strCallingProc & vbCrLf & _
"Error Number " & ErrorNum & vbCrLf & ErrorDes & vbCrLf & vbCrLf & _
"Unable to record because Error " & Err.Number & vbCrLf & Err.Description
MsgBox strMsg, vbCritical, "ErrorLog()"
Resume Exit_ErrorLog
End Function
Last edited: