My general thinking is to add procedures to all my module / class module objects (forms and reports) so that return the version... That way I can check each object's version and then check to see if it is the latest copy. Long story short we end up with a customized front end and backend from a base code... some of it has business rules in it that need centrally managed...
If I add code to a module... I can call it all is well...
If I add code to a report, I can't seem to call it even if I have the object open... I know I should be able to do this but I am at a loss... I've tried converting to a function just to see if it would work and nothing... I've tried a direct call like when I had it as a function...
debug.print Reports!RptWidget.rptWidgetVersion()
Ultimately I am trying to use something like the below. I will loop over known object names to check versions with this. This actually works for Modules... may need another version for reports. But I am at a loss as to calling the report call.
If I add code to a module... I can call it all is well...
Code:
Option Compare Database
Option Explicit
Const conmdlExampleversion As Long = 1
Public Sub mdlBrandVersion(Optional ByRef lngReturn As Variant = 0)
lngReturn = conmdlExampleversion
End Sub
If I add code to a report, I can't seem to call it even if I have the object open... I know I should be able to do this but I am at a loss... I've tried converting to a function just to see if it would work and nothing... I've tried a direct call like when I had it as a function...
debug.print Reports!RptWidget.rptWidgetVersion()
Code:
Option Compare Database
Option Explicit
Const conRptWidgetversion As Long = 1
Public Sub RptWidgetVersion(Optional ByRef lngReturn As Variant = 0)
lngReturn = conRptWidgetversion
End Sub
Ultimately I am trying to use something like the below. I will loop over known object names to check versions with this. This actually works for Modules... may need another version for reports. But I am at a loss as to calling the report call.
Code:
Public Function fnModuleVersion(ModuleName As String) As Long
Dim strCallName As String
strCallName = ModuleName & "Version"
Application.Run strCallName, fnModuleVersion 'fnModuleVersion is this function variable passed as a byRef Arg to be returned as the function return
Exit Function
fnModuleVersion_err:
Select Case Err.Number
Case 2517 '<Project Name> cannot find the procedure <ModuleName & "Version">
If ModuleExists(ModuleName) Then 'This User defined function works... Likely need a version of this for Reports
fnModuleVersion = -1 'Module Exists standard procedure does not... Likely a different animal
Else
fnModuleVersion = -2 'Module does not even exist in project... Likely don't need it?
End If
Case Else
MsgBox "Unhandled Error in fnModuleVersion" & vbCrLf & "Error " & Err.Number & ": " & Err.Description, vbCritical
End Select
End Function