G
Glint
Hi All,
Following a tip I got from the forum yesterday, I want to find a way to make
it easy to find redundant queries in my database, prior to deleting them.
Because the application is large, I may not find it easy to check each area
one at a time to see it it works after a query has been renamed temporarily.
I was thinking that it should be possible to find out if a query has been
used as a form's recordsouce; that done, I could find out if the said query
featured at all in any of the form's combo or list boxes row sources.
However, I have been stuck at the first stage: finding out if a query has
been the recordsource of any form. Here is what I tried, using the AllForms
collection:
If Not IsNull(T1) Then
strResults = ""
numFound = 0
Dim obj As AccessObject, dbs As Object, frm As Form
Set dbs = Application.CurrentProject
For Each obj In dbs.AllForms
If TypeOf obj Is Form Then
Set frm = obj
If frm.RecordSource = T1 Then
numFound = numFound + 1
strResults = strResults & vbNewLine & " " & numFound
& ") " & frm.Name
End If
End If
Next obj
Text3 = strResults
Exit Sub
End If
T1 and T 3 are textboxes; the query name goes into T1, while T3 should
display the outcome of the search. strResults is String, while numFound is
Long. The sub is in the event procedure of a command button.
Unfortunately, T3 fires blank even when T1 contains a query that I know has
been used as a recordsource for a form. What should I do?
Following a tip I got from the forum yesterday, I want to find a way to make
it easy to find redundant queries in my database, prior to deleting them.
Because the application is large, I may not find it easy to check each area
one at a time to see it it works after a query has been renamed temporarily.
I was thinking that it should be possible to find out if a query has been
used as a form's recordsouce; that done, I could find out if the said query
featured at all in any of the form's combo or list boxes row sources.
However, I have been stuck at the first stage: finding out if a query has
been the recordsource of any form. Here is what I tried, using the AllForms
collection:
If Not IsNull(T1) Then
strResults = ""
numFound = 0
Dim obj As AccessObject, dbs As Object, frm As Form
Set dbs = Application.CurrentProject
For Each obj In dbs.AllForms
If TypeOf obj Is Form Then
Set frm = obj
If frm.RecordSource = T1 Then
numFound = numFound + 1
strResults = strResults & vbNewLine & " " & numFound
& ") " & frm.Name
End If
End If
Next obj
Text3 = strResults
Exit Sub
End If
T1 and T 3 are textboxes; the query name goes into T1, while T3 should
display the outcome of the search. strResults is String, while numFound is
Long. The sub is in the event procedure of a command button.
Unfortunately, T3 fires blank even when T1 contains a query that I know has
been used as a recordsource for a form. What should I do?