D
Daniel
Hello,
I have the following code to determine the number of lines of code in a db.
******
Dim db As Database
Dim Doc As Document
Dim mdl As Module
Dim lngCount As Long
Dim lngFormsCode As Long
Dim lngReportsCode As Long
Dim i As Integer
Dim strForm As String
Set db = CurrentDb()
' count module LOC
For Each Doc In db.Containers("Modules").Documents
DoCmd.OpenModule Doc.Name
Set mdl = Modules(Doc.Name)
lngCount = lngCount + mdl.CountOfLines
'Debug.Print mdl.CountOfLines, Doc.Name
Set mdl = Nothing
DoCmd.Close acModule, Doc.Name
Next
'Debug.Print lngCount & " lines of code in Modules."
' count Code in Forms
For i = 0 To db.Containers("Forms").Documents.Count - 1
strForm = db.Containers("Forms").Documents(i).Name
DoCmd.OpenForm strForm, acDesign
lngFormsCode = lngFormsCode + Forms(strForm).Module.CountOfLines
'Debug.Print strForm, Forms(strForm).Module.CountOfLines
DoCmd.Close acForm, strForm, acSaveNo
Next
'Debug.Print "forms code = " & lngFormsCode
' count LOC in Reports
For i = 0 To db.Containers("Reports").Documents.Count - 1
strForm = db.Containers("Reports").Documents(i).Name
DoCmd.OpenReport strForm, acViewDesign
Reports(strForm).Visible = False
lngReportsCode = lngReportsCode + Reports(strForm).Module.CountOfLines
'Debug.Print strForm, Reports(strForm).Module.CountOfLines
DoCmd.Close acReport, strForm, acSaveNo
Next
'Debug.Print "reports code = " & lngReportsCode
'Debug.Print "total = " & lngFormsCode + lngCount + lngReportsCode
'***
NumCode = lngFormsCode + lngCount + lngReportsCode
******
The question being, is there no way to do this without having to open a form
in design mode. Basically run it while a db is up (forms open) and return
the results to a form?
Thank you,
Daniel
I have the following code to determine the number of lines of code in a db.
******
Dim db As Database
Dim Doc As Document
Dim mdl As Module
Dim lngCount As Long
Dim lngFormsCode As Long
Dim lngReportsCode As Long
Dim i As Integer
Dim strForm As String
Set db = CurrentDb()
' count module LOC
For Each Doc In db.Containers("Modules").Documents
DoCmd.OpenModule Doc.Name
Set mdl = Modules(Doc.Name)
lngCount = lngCount + mdl.CountOfLines
'Debug.Print mdl.CountOfLines, Doc.Name
Set mdl = Nothing
DoCmd.Close acModule, Doc.Name
Next
'Debug.Print lngCount & " lines of code in Modules."
' count Code in Forms
For i = 0 To db.Containers("Forms").Documents.Count - 1
strForm = db.Containers("Forms").Documents(i).Name
DoCmd.OpenForm strForm, acDesign
lngFormsCode = lngFormsCode + Forms(strForm).Module.CountOfLines
'Debug.Print strForm, Forms(strForm).Module.CountOfLines
DoCmd.Close acForm, strForm, acSaveNo
Next
'Debug.Print "forms code = " & lngFormsCode
' count LOC in Reports
For i = 0 To db.Containers("Reports").Documents.Count - 1
strForm = db.Containers("Reports").Documents(i).Name
DoCmd.OpenReport strForm, acViewDesign
Reports(strForm).Visible = False
lngReportsCode = lngReportsCode + Reports(strForm).Module.CountOfLines
'Debug.Print strForm, Reports(strForm).Module.CountOfLines
DoCmd.Close acReport, strForm, acSaveNo
Next
'Debug.Print "reports code = " & lngReportsCode
'Debug.Print "total = " & lngFormsCode + lngCount + lngReportsCode
'***
NumCode = lngFormsCode + lngCount + lngReportsCode
******
The question being, is there no way to do this without having to open a form
in design mode. Basically run it while a db is up (forms open) and return
the results to a form?
Thank you,
Daniel