Variable and Routine Scoping

All procedure and variable declarations made behind a form are private to that form and therefore are not accessible to other forms, macros, or global code.

Variable scoping in Microsoft Access version 2.0.

Therefore, to move values into and/or out of a form, place them in a global variable or a table where the value is reachable by code inside and outside the form. This applies to the Subform Wizard since the majority of its code is behind a form. To facilitate the transfer of the values, the following lines of code are added to the Subform Wizard's entry point. The first code added is the global variable declarations which we add to the declarations section of the entry point's module.


Global sg_stUserFrm As String
Global sg_stCtlName As String
Global sg_stCurrent As String

Next we add code to transfer parameter values to the global variables.


Function SF_EntryChild (stObjName As String, stCtlName As String, stCurVal As String) As String

    sg_stUserFrm = stObjName
    sg_stCtlName = stCtlName
    sg_stCurrent = stCurVal