[AccessD] Is it Possible to Have a Variable in a VBA "CALL"Statement?

Stuart McLachlan stuart at lexacorp.com.pg
Fri Jan 27 19:49:16 CST 2012


I would consider this much easier to follow. It encapsulates the conditional in it's own Sub 
and it is a simple Copy/Paste of two lines followed by a minor edit each time you add a new 
report:

Sub CommonCode(rptname as String)
'Do common stuff
.....
'Do specific Stuff
Call SpecificCode(rptname)
'Do more common stuff
.....
End Sub

Sub SpecificCode(rptName as String)
Select Case rptName
   Case "rptOne"
      Call rptOne_CompoundFilters
Case "rptTwo"
      Call rptTwo_CompoundFilters
Case "rptThree"
      Call rptThree_CompoundFilters
Case "rptFour"
      Call rptFour_CompoundFilters
End Select
End Sub


On 27 Jan 2012 at 19:13, Brad Marks wrote:

> 
> I have written a number of small chunks of VBA code to support
> "Compound Dynamic Report Filters".  Much of the code is "Common" code,
> but some of the code needs to be customized slightly for each Report. 
> 
> In the "common" code that calls the "Specialized" code, I current use
> IF statements to call the proper sub.  This will require one IF
> statement for each report (someday we might have 50+ reports) 
> 
> By being able to use a variable in the VBA CALL statement, we will be
> able to have just a few lines of code, instead of all the code needed
> to support 50+ different reports. 
> --
Stuart McLachlan

Ph:    +675 340 4392 
Mob: +675 7100 2028
Web: http://www.lexacorp.com.pg



More information about the AccessD mailing list