For Each tdf In db.TableDefs
doInclude = (Not CBool(tdf.Attributes And dbSystemObject)) And _
(Not CBool(tdf.Attributes And dbHiddenObject))
If (doInclude) Then
sql = ""
For Each fld In tdf.Fields
If fld.Type = 10 Then
sql = sql & "[" & fld.Name & "] like '*" & criteria & "*' or "
End If
Next
If sql <> "" Then
sql = "select * from [" & tdf.Name & "] where " & Left$(sql, Len(sql) - 3)
Debug.Print sql
Set rs = db.OpenRecordset(sql)
If Not rs.EOF Then
Set item = New SearchResults
item.Tablename = tdf.Name
rs.MoveFirst
ReDim items(0 To rs.Fields.Count - 1)
Do While Not rs.EOF
For j = 0 To rs.Fields.Count - 1
items(j) = rs.Fields(j).Value & vbNullString
Next
item.ResultRows.Add items
rs.MoveNext
Loop
For j = 0 To rs.Fields.Count - 1
item.ColumnNames.Add rs.Fields(j).Name
Next
results.Add item:=item, Key:=tdf.Name
End If
rs.Close
End If
End If
Next
Set SearchAllTables = results
exit_Search:
Set tdf = Nothing
Set fld = Nothing
Set rs = Nothing
Set db = Nothing
Exit Function
errhandler:
With Err
MsgBox "Error: " & .Number & vbCrLf & _
.Description, vbOKOnly Or vbCritical, "SearchAllTables"
End With
Resume exit_Search