View Full Version : String found in *deleted* query/form


Guus2005
08-20-2007, 04:12 AM
I've created a function to search for a string in SQL definitions:
Public Sub SearchInQueryDefs(strSearch As String)

Dim qdf As QueryDef
Dim qdfs As QueryDefs
Dim blnFound As Boolean

Set qdfs = CurrentDb.QueryDefs

For Each qdf In qdfs
blnFound = InStr(1, qdf.SQL, strSearch) > 0
If blnFound Then
Debug.Print "Searching : " & qdf.Name & "...";
Debug.Print " - found"
If vbNo = MsgBox("Found!" & vbCrLf & vbCrLf & "" & strSearch & " found in "

& qdf.Name & vbCrLf & vbCrLf & qdf.SQL & "" & vbCrLf & vbCrLf & "Click 'Yeah' to

continue search, 'Duh' to stop", vbExclamation + vbYesNo, "SearchInQueryDefs") Then
Exit Sub
End If
End If
Next qdf

MsgBox "Done searching.", vbInformation, GetAppTitle()
End Sub

Using the following statement (in the immediate window) i get the following result:
SearchInQueryDefs "Queries"
Searching : ~sq_cfrmReports~sq_clstQueries... - found
However query "~sq_cfrmReports~sq_clstQueries" doesn't exist.
It is probably a query which populates the listbox "lstQueries" in the "frmReports"

form. But that form doesn't exist in my database. I have deleted it some time ago. I

thought that Compact and Repair got rid of stuff like this.
I found the definition in the MsysObjects and with this Id also in the MsysQueries.
So my question is obvious: what is this, why is this and what can i do about it?

Thx!

Rabbie
08-20-2007, 04:23 AM
Without seeing your DB it is impossible to say why you are getting that hit. Since you could find it in MsysObjects and MsysQueries it does look like the query is still in your DB. I assume you cant see the query in your queries page.

Dennisk
08-20-2007, 04:46 AM
try creating an empty db and inporting all the objects then check again

The_Doc_Man
08-20-2007, 08:25 AM
Queries beginning with "~" (Tilde) are created underneath forms that have implied sorting, filtration, or other Access features where the form/report was created directly by a Wizard and you specified that sorting via the Wizard dialog.

They are quite real. DO NOT DELETE ONE. You will make some form or report go brain-dead.

Moniker
08-20-2007, 09:20 AM
Doc is ace on on this one. Access will automatically create queries when you apply filters/sorting to tables, queries, forms, and reports. Look at the Filter property and see what's there.

Guus2005
08-20-2007, 11:11 PM
Queries beginning with "~" (Tilde) are created underneath forms that have implied sorting, filtration, or other Access features where the form/report was created directly by a Wizard and you specified that sorting via the Wizard dialog.

They are quite real. DO NOT DELETE ONE. You will make some form or report go brain-dead.
Yes, i've figured that out.
~sq_cfrmReports~sq_clstQueriesRepresents a query in the frmReports form. It populates the lstQueries control.
~sq_ffrmReportsRepresents a query to which a form is bound.

But my frmReports form was deleted a few months back. I've compacted several times after that and still the MSysTables show this entry!

Why? Are you sure i can't delete this entry?

Guus2005
08-21-2007, 01:37 AM
No i can't. Access won't let me. Exporting all object to an empty database seems the only solution. But then i have to set Startup en References again.

So be it.

Seems like a bug to me. MSDN doesn't report it.
Thx for helping!