Text search in properties Access to objects

Is there a way in Access to search for specific text in object properties and so on? Just not just in the VBA source code.

I ask this because, for example, if I change the name of a field in a table, I have to check many properties of the object (Record Source, Control Source, Order By ...). This can be done using trail-and-error or by checking all the properties of each form control, but it takes a lot of time.

One option is Find and Replace (a good tool!), But for me it is a bit overwhelming. I don’t need to replace the text (only “find”), and this is $ 37 for a tool that I will use only a few times a year.

Other offers?

+5
source share
3 answers

There is something that I often use to find out where a function or request might be unexpected somewhere (in a related RowSource control inside a sub-request, for example).

I use an undocumented function to export all Access objects as raw text files.
Using a text editor that can recursively search in files under a folder (for example, free Notepad ++ ), I am sure that I will find all occurrences, however, that a certain line is buried.

The code for exporting all objects includes my IsBlank () function :

'====================================================================
' Name:    DocDatabase
' Purpose: Documents the database to a series of text files
' From:    http://www.datastrat.com/Code/DocDatabase.txt
' Author:  Arvin Meyer
' Date:    June 02, 1999
' Comment: Uses the undocumented [Application.SaveAsText] syntax
'          To reload use the syntax [Application.LoadFromText]
'          Modified to set a reference to DAO 8/22/2005
'          Modified by Renaud Bompuis to export Queries as proper SQL
'====================================================================
Public Sub DocDatabase(Optional path As Variant = Null)
    If IsBlank(path) Then
        path = Application.CurrentProject.path & "\" & Application.CurrentProject.Name & " - exploded view\"
    End If

    On Error Resume Next
    MkDir path 
    MkDir path & "\Forms\"
    MkDir path & "\Queries\"
    MkDir path & "\Queries(SQL)\"
    MkDir path & "\Reports\"
    MkDir path & "\Modules\"
    MkDir path & "\Scripts\"

    On Error GoTo Err_DocDatabase
    Dim dbs As DAO.Database
    Dim cnt As DAO.Container
    Dim doc As DAO.Document
    Dim i As Integer

    Set dbs = CurrentDb() ' use CurrentDb() to refresh Collections

    Set cnt = dbs.Containers("Forms")
    For Each doc In cnt.Documents
        Application.SaveAsText acForm, doc.Name, path & "\Forms\" & doc.Name & ".txt"
    Next doc

    Set cnt = dbs.Containers("Reports")
    For Each doc In cnt.Documents
        Application.SaveAsText acReport, doc.Name, path & "\Reports\" & doc.Name & ".txt"
    Next doc

    Set cnt = dbs.Containers("Scripts")
    For Each doc In cnt.Documents
        Application.SaveAsText acMacro, doc.Name, path & "\Scripts\" & doc.Name & ".txt"
    Next doc

    Set cnt = dbs.Containers("Modules")
    For Each doc In cnt.Documents
        Application.SaveAsText acModule, doc.Name, path & "\Modules\" & doc.Name & ".txt"
    Next doc

    Dim intfile As Long
    Dim filename as String
    For i = 0 To dbs.QueryDefs.count - 1
         Application.SaveAsText acQuery, dbs.QueryDefs(i).Name, path & "\Queries\" & dbs.QueryDefs(i).Name & ".txt"
         filename = path & "\Queries(SQL)\" & dbs.QueryDefs(i).Name & ".txt"
         intfile = FreeFile()
         Open filename For Output As #intfile
         Print #intfile, dbs.QueryDefs(i).sql
         Close #intfile
    Next i

    Set doc = Nothing
    Set cnt = Nothing
    Set dbs = Nothing

Exit_DocDatabase:
    Debug.Print "Done."
    Exit Sub

Err_DocDatabase:
    Select Case Err

    Case Else
        MsgBox Err.Description
        Resume Exit_DocDatabase
    End Select

End Sub

, DocDatabase Immediate Access IDE, " " .

+14

- NAME AUTOCORRECT. , , Access, - , .

, , . , , . , .

VBA. .. .

+1

I changed the code above to cut out temporary objects with "~" in the object name as follows:

Set cnt = dbs.Containers("Scripts")
For Each doc In cnt.Documents
    If Not doc.Name Like "~*" Then
        Application.SaveAsText acMacro, doc.Name, path & "\Scripts\" & doc.Name & ".txt"
    End If
Next doc
+1
source

All Articles