Wednesday, March 01, 2006

A scrolling list in IE

Since html code is not allowed with Blogger, click here for this post.

Looking for Babylon

I knew ‘babylon’ was part of a string in one of the fields in a MS Access database with 70 tables.

This program found it by running a query on all the fields in all the tables:

Private Sub Command0_Click()

Dim db As Database
Dim tdf As TableDef
Dim fld As Field
Dim rst As Recordset
Dim rst2 As Recordset
Dim csql As String
Dim cvalue As String

cvalue = "babylon"
On Error Resume Next
Set db = CurrentDb

For Each tdf In db.TableDefs
If LCase(Left(tdf.Name, 4)) <> "msys" Then
csql = "select * from " & tdf.Name
Set rst = CurrentDb.OpenRecordset(csql)
For Each fld In rst.Fields
' create a query to try to find cvalue anywhere in the field
csql = "select " & fld.Name & " from " & tdf.Name & " where lcase(" & fld.Name & ") like '*" & cvalue & "*'"
Set rst2 = CurrentDb.OpenRecordset(csql)
If Not (rst2.EOF And rst2.BOF) Then
MsgBox (tdf.Name & " - " & fld.Name)
End If
Next fld
End If
Next tdf

MsgBox "fin"

End Sub