Sub Routine

kitty77

Registered User.
Local time
Today, 05:08
Joined
May 27, 2019
Messages
716
I have a report that has several buttons on it. Send to a folder as a pdf, email, etc...
I created a sub rountine for those buttons. How can I use that same sub routine on other reports?

Thanks.
 
Put the sub routine in a Standard module. The routine will likely need arguments. Maybe something like

Code:
Public Sub SendToFolder (rpt as Access.report, SaveType as String)
  do code
end sub

now call it from your report

Code:
SendToFolder me, "PDF"
 
With a word of warning to be added to MajP's suggestion:

IF any of these routines that you intend to re-use includes the qualifier Me. or Me! for any control, it will not work correctly from the standard module. The Me reference is only valid within the class module that contains the given object for which that is a qualifier.

Note that he included Me in the calling sequence but in the common routine he included a formal parameter called rpt. In the standard module code, you would use rpt as your prefix.
 

Users who are viewing this thread

Back
Top Bottom