Guus2005
AWF VIP
- Local time
- Today, 12:33
- Joined
- Jun 26, 2007
- Messages
- 2,641
I have seen this string, in which table was it???
Here's the solution. Quick and Dirty but effective and quite fast.
Run it in the immediate window.
Feel free to abuse this code!
It is easy to search for fieldnames and fieldtypes as well.
Let me know what you think!
Share & Enjoy!
Here's the solution. Quick and Dirty but effective and quite fast.
Run it in the immediate window.
Feel free to abuse this code!
Code:
Option Compare Database
Option Explicit
Public Function SearchInTables(strValue As String) As String
'Search in almost *all* tables.
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim fld As DAO.Field
Dim rst As Recordset
Dim strSql As String
Set db = CurrentDb()
For Each tdf In db.TableDefs
If Left$(tdf.Name, 4) <> "MSys" Then
For Each fld In tdf.Fields
If fld.Type = 10 Or fld.Type = 12 Then 'Text or Memo field
strSql = "select [" & fld.Name & "] from " & tdf.Name & " where [" & fld.Name & "] like '*" & strValue & "*'"
Set rst = CurrentDb.OpenRecordset(strSql)
If Not rst.EOF Then
Debug.Print "Found in " & tdf.Name & ", field " & fld.Name & " value:" & rst.Fields(0)
End If
Set rst = Nothing
End If
Next fld
End If
Next tdf
MsgBox "Done"
End Function
It is easy to search for fieldnames and fieldtypes as well.
Code:
Debug.Print tdf.Name, fld.Name, fld.Type
Let me know what you think!
Share & Enjoy!