Glad it worked for you. I can see where you may want to find in multiple tables, I considered that, but haven't had time to get back to it. I think I'll steal your code :)
"Ronster" wrote:
[Quoted Text] > Excellent program Klatuu! And it's quick! Nice work. > > Since I need to be able to search all tables I have made some > modifications to your code. > > This will search all tables for one find only then move to the next > table. > > Function SearchAllTablesForValue(varFind As Variant) As String > > Dim tdfs As TableDefs > Dim rst As Recordset > Dim lngTblCount As Long > Dim lngFldCount As Long > Dim lngTblTot As Long > Dim lngFldTot As Long > Dim blnFoundIt As Boolean > > SearchAllTablesForValue = "Not Found" > Set tdfs = CurrentDb.TableDefs > lngTblTot = tdfs.Count - 1 > For lngTblCount = 0 To lngTblTot > Set rst = tdfs(lngTblCount).OpenRecordset > If rst.RecordCount <> 0 And Left(UCase(tdfs(lngTblCount).Name), 4) > <> "MSYS" Then > rst.MoveLast > rst.MoveFirst > Do While Not rst.EOF > lngFldTot = rst.Fields.Count - 1 > For lngFldCount = 0 To lngFldTot > If rst.Fields(lngFldCount).Type = dbLongBinary Then > lngFldCount = lngFldCount + 1 > End If > If rst.Fields(lngFldCount).Value = varFind Then > SearchAllTablesForValue = "Table - " & > tdfs(lngTblCount).Name & _ > Chr(13) & Chr(13) & "Field - " & > rst.Fields(lngFldCount).Name > MsgBox SearchAllTablesForValue, , "Searching For: > " & varFind > Exit Do > End If > Next lngFldCount > If lngTblCount >= lngTblTot Then > rst.Close > Exit For > Else > rst.MoveNext > End If > Loop 'While Not rst.EOF > rst.Close > End If > Next lngTblCount > > MsgBox "Search Complete" > > Set rst = Nothing > Set tdfs = Nothing > > End Function > > ' ***************************************** > > Sub MyTestSub() > > ' Examples: > ' DateValue("11/30/2005") (for 11/30/2005) > ' "moser" > ' 34704 > ' 13000 (for $13,000.00) > > SearchAllTablesForValue DateValue("11/30/2005") > > End Sub > >
|