Có điều gì đó tôi thường sử dụng để tìm ra nơi một số chức năng hoặc truy vấn có thể ẩn ở đâu đó không mong muốn (trong RowSource của một điều khiển bị ràng buộc trong một truy vấn phụ chẳng hạn).
Tôi sử dụng tính năng không có giấy tờ để xuất tất cả các đối tượng Access dưới dạng tệp văn bản thô.
Sử dụng trình soạn thảo văn bản có thể tìm kiếm trong các tệp đệ quy dưới một thư mục (ví dụ như ví dụ Notepad++ miễn phí). Tôi tự tin rằng tôi tìm thấy tất cả các lần xuất hiện, được chôn vùi, của một chuỗi cụ thể.
Bộ luật xuất khẩu tất cả các đối tượng bao gồm IsBlank() function tôi:
'====================================================================
' 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
Để sử dụng nó, chỉ cần gọi DocDatabase
từ cửa sổ ngay trong Access IDE, nó sẽ tạo ra một tập hợp các thư mục dưới và 'đã thúc đẩy View' thư mục chứa tất cả các tệp.
Nguồn
2011-06-20 10:46:44
tuyệt vời !! Cảm ơn bạn. – waanders
+1 Tôi đã thêm liên kết đến chức năng IsBlank(). Blog đẹp. Điều đó sẽ hữu ích cho tôi. – HansUp
Hãy nghĩ rằng tôi thích 'Đường dẫn tùy chọn hơn là String =" "', nhưng đó có lẽ chỉ là tôi tránh biến thể ở bất cứ đâu tôi có thể. – HansUp