Steven W. Erbach
serbach at new.rr.com
Mon Jul 7 11:37:30 CDT 2003
Jim, Here's the full tCount() function: ' Created : 1 Feb 1996 T.Best Function tCount(pstrField As String, pstrTable As String, pstrCriteria As String) As Long Dim dbCurrent As DAO.Recordset Dim rstLookup As DAO.Recordset Dim lngCount As Long On Error GoTo tCount_Err Set dbCurrent = DBEngine(0)(0) If pstrCriteria = "" Then If pstrField = "*" Or pstrField = "" Then Set rstLookup = dbCurrent.OpenRecordset("Select Count(*) From " & _ pstrTable, DB_OPEN_SNAPSHOT) Else Set rstLookup = glob.gDbs.OpenRecordset("Select Count(" & pstrField & ") From " & _ pstrTable, DB_OPEN_SNAPSHOT) End If Else If pstrField = "*" Or pstrField = "" Then Set rstLookup = glob.gDbs.OpenRecordset("Select Count(*) From " & _ pstrTable & " Where " & pstrCriteria, DB_OPEN_SNAPSHOT) Else Set rstLookup = glob.gDbs.OpenRecordset("Select Count(" & pstrField & ") From " & _ pstrTable & " Where " & pstrCriteria, DB_OPEN_SNAPSHOT) End If End If If Not rstLookup.BOF Then rstLookup.MoveFirst lngCount = rstLookup(0) Else lngCount = 0 End If rstLookup.Close tCount = lngCount tCount_Exit: On Error Resume Next rstLookup.Close Exit Function tCount_Err: Select Case Err Case Else End Select ' Retry/Abort/Ignore Select Case MsgBox(Error, MB_ABORTRETRYIGNORE Or MB_ICONEXCLAMATION, _ "Error " & Err) Case IDABORT Resume tCount_Exit Case IDRETRY Resume Case IDIGNORE Resume Next End Select End Function Again, the problem occurs in the tCount_Exit subroutine after tCount has been successfully set to lngCount in the body of the function. The On Error Resume Next is simply ignored. Thanks, Jim. Regards, Steve Erbach Scientific Marketing Neenah, WI "Nothing so needs reforming as other people's habits." - Mark Twain