Hi Guys (girls),
I am pretty new to this, but I have a problem wich I can't seem tot tackle. I need some advanced help.
What I would like to do is create a search that will go trough one table called tblIP_Sheet. This table is filled with loads of IP adresses.
I am looking for a module that will go trough the entire table and list me all the hits found.
I allready tried it with a query, but wasn't able to get that working, tried it with the following module but also wasn't able to get it working the way I would like to.
Option Compare Database
Sub FullLIKESearch()
Dim rs As Recordset, tdf As TableDef, fld As Field, strSearch As String, iResp As Integer
'Search EVERY TABLE, EVERY FIELD in a database for a text string (substring, really)
strSearch = "0" 'this will be parameterized in the sub definition
For Each tdf In CurrentDb.TableDefs
If Left(tdf.Name, 4) = "MSys" Then GoTo lblNextTable
On Error GoTo errFullSearch1
Set rs = CurrentDb.OpenRecordset(tdf.Name, dbOpenDynaset)
On Error GoTo 0
rs.MoveLast
If rs.RecordCount * rs.Fields.Count > CLng(300000) Then
iResp = MsgBox("Okay to do " & rs.Fields.Count & " fields for " _
& rs.RecordCount & " records in " & tdf.Name & " ?", vbYesNo)
If iResp <> vbYes Then Debug.Print "skipped " & tdf.Name: GoTo lblNextTable
End If
'Debug.Print tdf.Name
For Each fld In rs.Fields
'Debug.Print "field " & fld.Name
rs.FindFirst "[" & fld.Name & "] LIKE " & "'*" & strSearch & "*'"
'rs.FindFirst "[" & fld.Name & "] = " & "'*" & strSearch & "*'"
If Not rs.NoMatch Then Debug.Print tdf.Name, fld.Name, strSearch: GoTo lblNextTable
Next fld
lblNextTable:
Next tdf
Debug.Print "DONE"
rs.Close: Set rs = Nothing
Exit Sub
errFullSearch1:
Debug.Print "problem opening " & tdf.Name
Resume lblNextTable
End Sub
Some tips/tricks/help or examples are greatly appreciated....