Skip to content

Commit

Permalink
remove empty modules if no more lines then 2 are counted
Browse files Browse the repository at this point in the history
add function to remove temp objects from access, they can be found in the msysobjects table prefixed as ~
add function to dump all form names to a table
  • Loading branch information
RaoulJacobs committed May 12, 2020
1 parent 76266fe commit 3584105
Showing 1 changed file with 41 additions and 2 deletions.
43 changes: 41 additions & 2 deletions M_omLibraryFunctions.def
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ Dim msgBoxResult As VbMsgBoxResult

For i = VBE.ActiveVBProject.VBComponents.Count To 1 Step -1
Set F = VBE.ActiveVBProject.VBComponents(i)
If F.CodeModule.CountOfLines = F.CodeModule.CountOfDeclarationLines Then
If F.CodeModule.CountOfLines = F.CodeModule.CountOfDeclarationLines AND F.CodeModule.CountOfLines<3 Then
msg = F.Name
If F.CodeModule.CountOfLines > 0 Then
msg = msg & vbCrLf & F.CodeModule.Lines(1, F.CodeModule.CountOfLines)
Expand Down Expand Up @@ -467,4 +467,43 @@ Public Sub Commit()

' cmdshell exeute git -c -p folder, msg

End Sub
End Sub

Public Sub RemoveDeletedObjects()
Dim rs As New ADODB.Recordset
Dim objType As AcObjectType

rs.Open "SELECT Name,Type FROM MSysobjects WHERE Name LIKE '~%'", CurrentProject.connection, adOpenForwardOnly, adLockReadOnly
While Not rs.EOF

Select Case rs("Type")
Case 5
objType = acQuery
Case -32766
objType = acMacro
Case Else
objType = 0
msgbox "ObjectType Not Defined " & rs("type")
End Select
If objType <> 0 Then
DoCmd.DeleteObject objType, rs("Name")
End If
rs.MoveNext
Wend
rs.Close
Set rs = Nothing
End Sub

Public Sub ListFormsToTable()
Dim rs As New ADODB.Recordset
Dim f As AccessObject

rs.Open "___T_Forms", CurrentProject.connection, adOpenForwardOnly, adLockOptimistic
For Each f In CodeProject.AllForms
rs.AddNew
rs("Name") = f.Name
rs.Update
Next
rs.Close
Set rs = Nothing
End Sub

0 comments on commit 3584105

Please sign in to comment.