Sub ProduceStats()
Rem*******************************************
Rem 2017.04.04.04 Set Up
Rem*******************************************
Dim s1 As String
Dim v1 As Variant
On Error GoTo oops
Rem*******************************************
Rem 2017.04.04.04 Table Stats
Rem*******************************************
Dim NoOfTables As Long, NoOfFields As Long, NoOfRecords As Long
For Each v1 In CurrentDb.TableDefs
NoOfTables = NoOfTables + 1
NoOfFields = NoOfFields + v1.Fields.Count
NoOfRecords = NoOfRecords + DCount("*", v1.Name)
Next v1
Rem*******************************************
Rem 2017.04.04.04 Form Stats
Rem*******************************************
Dim NoOfForms As Long, NoOfControls As Long, NoOfModules As Long
Dim NoOfFunctions As Long, CodeLines As Long, LineNumber As Long
For v1 = 0 To CurrentDb.Containers("Forms").Documents.Count - 1
s1 = CurrentDb.Containers("Forms").Documents(v1).Name
NoOfForms = NoOfForms + 1
DoCmd.OpenForm s1, acDesign, , , , acHidden
NoOfControls = NoOfControls + Forms(s1).Controls.Count
If Forms(s1).HasModule = True Then
NoOfModules = NoOfModules + 1
CodeLines = CodeLines + Forms(s1).Module.CountOfLines
For LineNumber = 1 To Forms(s1).Module.CountOfLines
If Trim(UCase(Forms(s1).Module.Lines(LineNumber, 1))) Like "FUNCTION *" _
Or Trim(UCase(Forms(s1).Module.Lines(LineNumber, 1))) Like "SUB *" _
Or Trim(UCase(Forms(s1).Module.Lines(LineNumber, 1))) Like "PRIVATE FUNCTION *" _
Or Trim(UCase(Forms(s1).Module.Lines(LineNumber, 1))) Like "PRIVATE SUB * " Then
NoOfFunctions = NoOfFunctions + 1
End If
Next LineNumber
End If
DoCmd.Close acForm, s1, acSaveYes
Next v1
Rem*******************************************
Rem 2017.04.04.04 Reports
Rem*******************************************
Dim NoOfReports As Long
For v1 = 0 To CurrentDb.Containers("Reports").Documents.Count - 1
s1 = CurrentDb.Containers("Reports").Documents(v1).Name
NoOfReports = NoOfReports + 1
DoCmd.OpenReport s1, acDesign, , , , acHidden
NoOfControls = NoOfControls + Reports(s1).Controls.Count
If Reports(s1).HasModule = True Then
CodeLines = CodeLines + Reports(s1).Module.CountOfLines
For LineNumber = 1 To Reports(s1).Module.CountOfLines
If Trim(UCase(Reports(s1).Module.Lines(LineNumber, 1))) Like "FUNCTION *" _
Or Trim(UCase(Reports(s1).Module.Lines(LineNumber, 1))) Like "SUB *" _
Or Trim(UCase(Reports(s1).Module.Lines(LineNumber, 1))) Like "PRIVATE FUNCTION *" _
Or Trim(UCase(Reports(s1).Module.Lines(LineNumber, 1))) Like "PRIVATE SUB * " Then
NoOfFunctions = NoOfFunctions + 1
End If
Next LineNumber
End If
DoCmd.Close acReport, s1, acSaveYes
Next v1
Rem*******************************************
Rem 2017.04.04.04 Modules
Rem*******************************************
For v1 = 0 To CurrentProject.AllModules.Count - 1
s1 = CurrentProject.AllModules(v1).Name
DoCmd.OpenModule s1
CodeLines = CodeLines + Modules(s1).CountOfLines
For LineNumber = 1 To Modules(s1).CountOfLines
If Trim(UCase(Modules(s1).Lines(LineNumber, 1))) Like "FUNCTION *" _
Or Trim(UCase(Modules(s1).Lines(LineNumber, 1))) Like "SUB * " Then
NoOfFunctions = NoOfFunctions + 1
End If
Next LineNumber
On Error Resume Next
DoCmd.Close acModule, s1, acSaveYes
On Error GoTo oops
Next v1
Rem*******************************************
Rem 2017.04.04.04 Compile Message
Rem*******************************************
s1 = "Tables : = " & NoOfTables & vbNewLine
s1 = s1 & "Fields : = " & NoOfFields & vbNewLine
s1 = s1 & "Records : = " & NoOfRecords & vbNewLine
s1 = s1 & "Forms : = " & NoOfForms & vbNewLine
s1 = s1 & "Reports : = " & NoOfReports & vbNewLine
s1 = s1 & "Controls : = " & NoOfControls & vbNewLine
s1 = s1 & "Functions : = " & NoOfFunctions & vbNewLine
s1 = s1 & "Lines Of Code := " & CodeLines
MsgBox s1
Rem*******************************************
Rem 2017.04.04.04 finished
Rem*******************************************
Exit Sub
oops:
MsgBox Error$
End Sub