jason_nevin
Registered User.
- Local time
- Today, 08:04
- Joined
- Nov 22, 2002
- Messages
- 46
I have some cde in which I'm trying to ignore error 3349 whenever it occurs. The code ignores it fine the first time but the second time the error occurs the code does not seen to go into the error handler. Can anyone help?
Private Sub butGo_Click()
Dim db As DAO.database
Dim tdf As DAO.tabledef
Dim rst As DAO.Recordset
Dim f As Integer
Dim SearchString As String
Dim TableName As String
Dim FieldName As String
Dim LookupString As String
Dim RowNo As Integer
On Error GoTo HandleErrors
SearchString = "Pearce"
Set db = CurrentDb()
' get the names of all tables in the database
For Each tdf In db.TableDefs
' ignore system tables
If Left$(tdf.Name, 4) = "MSys" Then
GoTo Next_Rec
End If
TableName = tdf.Name
Debug.Print "Searching table " & TableName
Set rst = db.OpenRecordset(TableName)
RowNo = 1
With rst
Do Until .EOF
.MoveNext
RowNo = RowNo + 1
Debug.Print RowNo
' loop each column in the table
For f = 0 To rst.Fields.Count - 1
' only search general fields (not numeric)
If .Fields(f).Type = 10 Then
FieldName = .Fields(f).Name
If Not IsNumeric(.Fields(f).Value) And _
Not IsNull(.Fields(f).Value) Then
If InStr(.Fields(f).Value, SearchString) > 0 Then
' Debug.Print RowNo
End If
End If
ResumeHere:
End If
Next
Loop
.Close
Set rst = Nothing
End With
Next_Rec:
Next tdf
Set db = Nothing
Set tdf = Nothing
ExitHere:
Exit Sub
HandleErrors:
Select Case Err.Number
Case 3349
Err.Clear
GoTo ResumeHere
Case Else
MsgBox "Error: " & Err.Description & _
" (" & Err.Number & ")"
End Select
Resume ExitHere
End Sub
Private Sub butGo_Click()
Dim db As DAO.database
Dim tdf As DAO.tabledef
Dim rst As DAO.Recordset
Dim f As Integer
Dim SearchString As String
Dim TableName As String
Dim FieldName As String
Dim LookupString As String
Dim RowNo As Integer
On Error GoTo HandleErrors
SearchString = "Pearce"
Set db = CurrentDb()
' get the names of all tables in the database
For Each tdf In db.TableDefs
' ignore system tables
If Left$(tdf.Name, 4) = "MSys" Then
GoTo Next_Rec
End If
TableName = tdf.Name
Debug.Print "Searching table " & TableName
Set rst = db.OpenRecordset(TableName)
RowNo = 1
With rst
Do Until .EOF
.MoveNext
RowNo = RowNo + 1
Debug.Print RowNo
' loop each column in the table
For f = 0 To rst.Fields.Count - 1
' only search general fields (not numeric)
If .Fields(f).Type = 10 Then
FieldName = .Fields(f).Name
If Not IsNumeric(.Fields(f).Value) And _
Not IsNull(.Fields(f).Value) Then
If InStr(.Fields(f).Value, SearchString) > 0 Then
' Debug.Print RowNo
End If
End If
ResumeHere:
End If
Next
Loop
.Close
Set rst = Nothing
End With
Next_Rec:
Next tdf
Set db = Nothing
Set tdf = Nothing
ExitHere:
Exit Sub
HandleErrors:
Select Case Err.Number
Case 3349
Err.Clear
GoTo ResumeHere
Case Else
MsgBox "Error: " & Err.Description & _
" (" & Err.Number & ")"
End Select
Resume ExitHere
End Sub