locked
Access 2010 Web App - Scope of Local Variables? RRS feed

  • Question

  • Can a local variable declared at the Form level be accessible from a Macro at one of the Forms contained controls or is it better to just place an invisible control on the main form and allow the other controls on the form to use that?

    Thanks!


    Νικοσ Γιαννιοσ

    Tuesday, February 17, 2015 9:13 PM

Answers

  • Each local var is limited to the code JUST in that event. However, if you declare the var as tempvar (global), then such variables are available to all macros for the life of the form.

    Presumably, then you could use a variable in place of some text box set as invisible (visible = false).

    So event code can create and use both local vars (SetLocalVar)) and that of global (SetTempVar).


    Regards,
    Albert D. Kallal (Access MVP)
    Edmonton, Alberta Canada

    Wednesday, February 18, 2015 4:11 AM

All replies

  • Each local var is limited to the code JUST in that event. However, if you declare the var as tempvar (global), then such variables are available to all macros for the life of the form.

    Presumably, then you could use a variable in place of some text box set as invisible (visible = false).

    So event code can create and use both local vars (SetLocalVar)) and that of global (SetTempVar).


    Regards,
    Albert D. Kallal (Access MVP)
    Edmonton, Alberta Canada

    Wednesday, February 18, 2015 4:11 AM
  • Thanks!

    Νικοσ Γιαννιοσ

    Thursday, February 19, 2015 7:03 PM