Wednesday, March 01, 2006
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
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
Sunday, February 12, 2006
Laborious alignment
If three objects have the same height and are aligned with their tops will they align?
If you use Crystal Reports for Visual Studio the answer is no if two of them are strings and one is a number.

The middle object in the image is a number, the other two are strings.
How did I make the number into a string? By using a formula field: formula = "$" & totext(Sum ({phonereport_temp.cost}),2).
If you use Crystal Reports for Visual Studio the answer is no if two of them are strings and one is a number.

The middle object in the image is a number, the other two are strings.
How did I make the number into a string? By using a formula field: formula = "$" & totext(Sum ({phonereport_temp.cost}),2).
Monday, January 23, 2006
Running executables from Internet Explorer
My friend John has solved a problem I was unable to solve two years ago: how to run an executable from Internet Explorer without meeting any warning messages on your way.
I wanted to create a easily customised application menu for my students. Eventually I wrote it in Visual Basic.
Here is a web page that will run Excel when you click the button:

Two things (click Log in as a guest) has to done to IE for this to work for any web server. I used http://localhost to test the idea.
1. Tools - Internet Options - Security - Trusted sites - Sites - Uncheck 'Require server verification ...' - Type 'http://localhost' and click the Add button - OK - OK.
2. Tools - Internet Options - Security - Custom Level - Enable 'Initialize and script ActiveX controls not marked as safe.
The second part is a bit scary. What kind of unsafe code may now run on my machine?
I wanted to create a easily customised application menu for my students. Eventually I wrote it in Visual Basic.
Here is a web page that will run Excel when you click the button:

Two things (click Log in as a guest) has to done to IE for this to work for any web server. I used http://localhost to test the idea.
1. Tools - Internet Options - Security - Trusted sites - Sites - Uncheck 'Require server verification ...' - Type 'http://localhost' and click the Add button - OK - OK.
2. Tools - Internet Options - Security - Custom Level - Enable 'Initialize and script ActiveX controls not marked as safe.
The second part is a bit scary. What kind of unsafe code may now run on my machine?
Subscribe to:
Posts (Atom)