Making a parameter passed to a SUB available to all SUBS in the module

  • Thread starter Thread starter David C. Holley
  • Start date Start date
D

David C. Holley

The Subject basically asks my question, but to elaborate. How do I make
a value passed in a parameter to a SUB available to all SUBS in the
module. Basically, I want updateAdvisory() to be able to see
ynShowAdvisory without having to pass the value to it.

Sub runOutlookInterface(lngTransportId As Long, ynShowAdvisory As Boolean)

Private Sub updateAdvisory(strAdvisoryText As String)
 
Would Property Let / Property Get work for you? I use custom properties
assigned to forms or reports to share values as you describe.

Randall Arnold
 
Dim the variable at the module level. (At the top of the module before any
procedures). However, the way you are doing it by passing the value is the
better approach.
 
Dimming the value at the Object level doesn't work. Did you catch that
both SUBS are in the same free-standing module and that I want the
updateAdvisory SUB to read the ynShowAdvisory value passed to
runOutlookInterface()
 
Sorry, I did not catch that. You did not say free-standing before and I
assumed you meant they were all in a form module. You will have to make
ynShowAdvisory a Global variable, I think. I still think the way you are
doing it now is the better way.
 
I ended up DIM a module-level variable ynShowAdvisoryForm and then just
setting its value to the parameter in the SUB. I think though that itd
be QUITE useful for the other modules to be able to see the parameters
passed to any of their PUBLIC SUB/FUNCTION siblings.
 
Back
Top