Declaring Procedures as Public or Private

 < Day Day Up > 

You won't always see procedures declared with just the Sub or Function keyword. There are various modifiers that can go in front of these keywords. Two of the important modifiers are Public and Private. A public procedure can be called from anywhere within your Access VBA code. A private procedure can only be called from within the module where it is declared. Here's how these declarations look, in procedures that don't actually do anything:

 

 Public Sub Procedure10()   ' Can be called from anywhere End Sub Private Sub Procedure11()   ' Can only be called from this module End Sub Public Function Procedure12()   ' Can be called from anywhere End Function Private Function Procedure13()   ' Can only be called from this module End Function 

CAUTION

Private procedures can't be called from the Immediate window.


     < Day Day Up > 


    Automating Microsoft Access with VBA
    Automating Microsoft Access with VBA
    ISBN: 0789732440
    EAN: 2147483647
    Year: 2003
    Pages: 186

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net