Gasman
Enthusiastic Amateur
- Local time
- Today, 17:51
- Joined
- Sep 21, 2011
- Messages
- 15,661
OK, internet was down at my house for some of the morning, so I decided just to browse Northwind 2007.
They have an error logging routine
Nothing wrong with that you might say, but the name of the module LogError is in is actually called ErrorHandling ?
Include pic of left window
So my question is, how does Access recognise eh. as Errorhandling?, as you can see in the first code block they actually use the whole name for RecordsetWrapper.
They have an error logging routine
Code:
Option Compare Database
Option Explicit
Private m_rs As DAO.Recordset2
Public Function OpenRecordset(Domain As String, _
Optional Criteria As String = "1=1", _
Optional OrderBy As String, _
Optional RecordsetType As DAO.RecordsetTypeEnum = dbOpenDynaset, _
Optional RecordsetOptions As DAO.RecordsetOptionEnum _
) As Boolean
If Not m_rs Is Nothing Then
' Close the recordset so it can be re-used
CloseRecordset
End If
Dim strSQL As String
strSQL = "SELECT * FROM [" & Domain & "] WHERE " & Criteria
If OrderBy <> "" Then
strSQL = strSQL & " ORDER BY " & OrderBy
End If
On Error GoTo ErrorHandler
Set m_rs = CurrentDb.OpenRecordset(strSQL, RecordsetType, RecordsetOptions)
OpenRecordset = True
Done:
Exit Function
ErrorHandler:
' verify the private Recordset object was not set
Debug.Assert m_rs Is Nothing
' Resume statement will be hit when debugging
If eh.LogError("RecordsetWrapper.OpenRecordset", "strSQL = " & Chr(34) & strSQL & Chr(34)) Then Resume
End Function
Code:
Public Function LogError(strLocation As String, ParamArray State()) As Boolean
Dim strMsg As String
Dim strState As String
' Build the error message to display
strMsg = Err.Description & " (" & Err.Number & ")" & vbCrLf & vbCrLf & strLocation
strState = Join(State, vbCrLf)
If strState <> "" Then
strMsg = strMsg & vbCrLf & vbCrLf & strState
End If
' Display the error
MsgBox strMsg, vbCritical
' If debugging is supported, break using Debug.Assert.
If DebuggingSupported() Then
Debug.Assert False ' Stop code so that you can debug
LogError = True ' Step over this line if you don't want to resume
End If
End Function
So my question is, how does Access recognise eh. as Errorhandling?, as you can see in the first code block they actually use the whole name for RecordsetWrapper.