Skip to content

Instantly share code, notes, and snippets.

@TSKGunGun
Created February 7, 2017 00:40
Show Gist options
  • Save TSKGunGun/bbc7760b6ee640c223f871cc5e401d16 to your computer and use it in GitHub Desktop.
Save TSKGunGun/bbc7760b6ee640c223f871cc5e401d16 to your computer and use it in GitHub Desktop.
Access分析ツール
'------------------------------------------------------
'Software Name: Access 分析ツール
'FileName: AccessAnalyzer
'Author: Suguru Ueda
'Last Modifiy:2017/2/7
'------------------------------------------------------
Option Compare Database
Option Explicit
'テーブル情報表示
Public Sub ShowTableInfo()
Dim RecordCount As Long
RecordCount = 0
Dim TableItem As AccessObject
Dim i As Integer
For i = 0 To Application.CurrentData.AllTables.Count - 1
Set TableItem = Application.CurrentData.AllTables(i)
'AccessのシステムテーブルはMSys...から始まるので除外する
If Left(TableItem.Name, 4) = "MSys" Then GoTo continue
Debug.Print "TableName:" + TableItem.Name + " Records: " + CStr(DCount("*", TableItem.Name))
RecordCount = RecordCount + DCount("*", TableItem.Name)
continue:
Next
'Accessのシステムテーブルが15個あるので減算
Debug.Print "TableCount:" & CStr(Application.CurrentData.AllTables.Count - 15) + _
" TotalRecords : " + CStr(RecordCount)
End Sub
'クエリ情報表示
Public Sub ShowQueryInfo()
Dim QueryItem As AccessObject
Dim i As Integer
For i = 0 To Application.CurrentData.AllQueries.Count - 1
Set QueryItem = Application.CurrentData.AllQueries(i)
Debug.Print "QueryName:" + QueryItem.Name
Next
Debug.Print "QueryCount:" & Application.CurrentData.AllQueries.Count
End Sub
'レポート情報表示
Public Sub ShowReportsInfo()
Dim ReportItem As AccessObject
Dim i As Integer
For i = 0 To Application.CodeProject.AllReports.Count - 1
Set ReportItem = Application.CodeProject.AllReports.Item(i)
Debug.Print "ReportName:" + ReportItem.Name
Next
Debug.Print "ReportCount:" & Application.CodeProject.AllReports.Count
End Sub
'モジュール情報表示
Public Sub ShowCordInfo()
Dim LineCount As Long
LineCount = 0
Dim ModItem As Module
Dim i As Integer
For i = 0 To Application.Modules.Count - 1
Set ModItem = Application.Modules.Item(i)
Debug.Print "ModuleName:"; ModItem.Name & " LineCount:" & ModItem.CountOfLines
LineCount = LineCount + ModItem.CountOfLines
Next
Debug.Print "TotalLines:" & LineCount
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment