waa*_*ers 7 ms-access ms-access-2007 ms-access-2010
Access中有没有办法搜索对象属性中的某个文本等等?不仅仅是在VBA源代码中.
我问这个是因为如果我改变一个表中字段的名称,我要检查很多对象属性(Record Source,Control Source,Order By,...).这可以通过跟踪错误或通过检查表单的每个控件的所有属性来完成,但这需要花费很多时间.
一个选项是查找和替换工具(漂亮的工具!),但它对我来说有点矫枉过正.我不需要文本替换(只有'查找'),一个工具只需37美元,我一年只会使用几次.
其他建议?
Ren*_*uis 15
我经常使用一些东西来找出某些函数或查询可能隐藏在某处意外的位置(例如在子查询中的绑定控件的RowSource中).
我使用未记录的功能将所有Access对象导出为原始文本文件.
使用文本编辑器可以在文件夹下递归搜索文件(例如免费的Notepad ++),然后我确信我会发现特定字符串的所有事件,无论多么埋没.
导出所有对象的代码包括我的IsBlank()函数:
'====================================================================
' 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
Run Code Online (Sandbox Code Playgroud)
要使用它,只需DocDatabase
从Access IDE中的立即窗口调用,它将在"爆炸视图"文件夹下创建一组目录,其中包含所有文件.
归档时间: |
|
查看次数: |
6125 次 |
最近记录: |