×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Can't call procedure on Report... Working on detecting out of date objects for auto update

Can't call procedure on Report... Working on detecting out of date objects for auto update

Can't call procedure on Report... Working on detecting out of date objects for auto update

(OP)
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...

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 

RE: Can't call procedure on Report... Working on detecting out of date objects for auto update

(OP)
So way down there in the Google results.... And I mean way down there...


https://www.access-programmers.co.uk/forums/thread...

My way should work according to thread but using the class module name with the object type prefix worked in my case for immediate window syntax...

CODE

Report_RptWidget.RptWidgetVersion  'Not the class name is "Report_" Followed by the Report Name.  
                                   'Class name also visible in the title bar of the Visual Basic editor when the report class is open
                                   'Calling an unopened report this way apparently instantiates the class hidden 
                                      'and out side of the typical collection (Reports) and will remain open until a regular instance is opened and closed.
                                      'Caveat: This special hidden instance fires open and load events when instantiated and unload and close when closed.... 

RE: Can't call procedure on Report... Working on detecting out of date objects for auto update

(OP)
So then the next logical step...

Does not work... The procedure does not exist which I expected per another one of my threads or so I thought... I can't find it now.

CODE

Public Function fnReportVersion(ReportName As String) As Long
  Dim strCallName As String
  
  strCallName = "Report_" & ReportName & "." & ReportName & "Version"
  Application.Run strCallName, fnReportVersion 'fnModuleVersion is this function variable passed as a byRef Arg to be returned as the function return

Exit Function

End Function 

RE: Can't call procedure on Report... Working on detecting out of date objects for auto update

(OP)
Assuming the report will run a property would work... My catch 22 is that the recordsource is created by other code on data that may not be present.
Still looking for a good option.

CODE

Public Function fnReportVersion(ReportName As String) As Long
  Dim rpt As Report
  
  DoCmd.OpenReport ReportName, acViewNormal
  fnReportVersion = Reports(ReportName).Version

End Function 


CODE

'Property on the Report
Public Property Get Version() As Long
  Version = conrpt_CoverFaxVersion
End Property 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close