Search within MS Access Queries

Jerry8989

Registered User.
Local time
Today, 14:09
Joined
Mar 16, 2006
Messages
64
Does anyone know of a way that I could search all of my queries and VBA Code for specific columns? We add and remove columns all the time and our reports and forms crash when we miss taking them all out. We have so many that it is very hard to do manually.

Thank for any help
 
Hello:

the below code would cycle through all the fields in a table or query and display the title of the column in a message box:

On Error GoTo Procedure_Error
Dim db As Database
Dim rs As DAO.Recordset
Dim fld As Field
Dim strRowSource As String
'
Set db = CurrentDb()
Set rs = db.OpenRecordset("tblAscii")
'
MsgBox "Date this recordset created: " & rs.DateCreated
MsgBox "Number of field(s) in this recordset = " & rs.Fields.Count
For Each fld In rs.Fields
MsgBox fld.Name
'Do some more work here

Next fld
'
rs.Close
CurrentDb.Close
***********************
To cycle through the list of available queries in a database you could use the ALLQueries Collection such as:

Sub AllQueries()
Dim obj As AccessObject, dbs As Object
Set dbs = Application.CurrentData
' Search for open AccessObject objects in AllQueries collection.
For Each obj In dbs.AllQueries
If obj.IsLoaded = True Then
' Print name of obj.
Debug.Print obj.Name
End If
Next obj
End Sub
'
Regards
Mark
 
Hello: Be sure to substitute your table name for the tblAscii entry in the code.
Mark
 
Thanks

Thank You everyone for all your help. It helped so much.
 

Users who are viewing this thread

Back
Top Bottom