属性访问对象中的文本搜索 [英] Text-search in properties Access objects

查看:53
本文介绍了属性访问对象中的文本搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Access中是否有一种方法可以在对象属性等中搜索特定文本?不仅在VBA源代码中.

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

我之所以这样问是因为,例如,如果要更改表中字段的名称,则必须检查许多对象属性(记录源,控制源,排序依据...).可以通过错误检查或检查表单每个控件的所有属性来完成,但这会花费很多时间.

I'm asking this because if I change for example the name of a field in a table I've to check a lot of object properties (Record Source, Control Source, Order By, ...). This can be done by trail-and-error or by checking all properties of each control of the forms, but that takes a lot of time.

一种选择是查找和替换工具(很好的工具!),但这有点对我来说太过分了我不需要替换文字(只需查找"即可),而我一年只使用几次的工具的价格为37美元.

One option is the Find and Replace tool (nice tool!), but it's a bit of overkill for me. I don't need a text replace (only 'find') and it's 37 dollar for a tool I'll only use a few times a year.

其他建议?

推荐答案

我经常使用一些东西来找出某些函数或查询可能隐藏在意外地方的地方(例如,在子查询内的绑定控件的RowSource中). ).

There is something I often use to find out where some function or query may be hidding somewhere unexpected (in a bound control's RowSource of within a sub-query for instance).

我使用一种未记录的功能将所有Access对象导出为原始文本文件.
使用文本编辑器可以在文件夹下递归搜索文件(例如免费的 Notepad ++ )然后,我有信心找到所有出现在特定字符串中的东西,无论它是怎么掩埋的.

I use an undocumented feature to export all Access objects as raw text files.
Using a text editor that can search within files recursively under a folder(like the free Notepad++ for instance) I am then confident that I find all occurrences, however buried, of a particular string.

用于导出所有对象的代码包括我的 IsBlank()函数:

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

要使用它,只需在Access IDE的即时"窗口中调用DocDatabase,它将在爆炸视图"文件夹下创建一组目录,其中将包含所有文件.

To use it, just call DocDatabase from the Immediate window in the Access IDE, it will create a set of directories under and 'Exploded View' folder that will contain all the files.

这篇关于属性访问对象中的文本搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆