Forum home » Delegate support and help forum » Microsoft Access Training and help » VBA declaring Public variables for use with forms -question for
VBA declaring Public variables for use with forms -question for
Resolved · Low Priority · Version 2007
Kathy has attended:
Access Introduction course
Access Intermediate course
Access VBA course
VBA declaring Public variables for use with forms -question for
Hi,
Please can you tell me how I can use Public variables in Access VBA, if I'm working with forms, and giving the variables their values in the form modules.
I've tried declaring the variable in the form modules and in the standard modules. But if the variable gets its value from the form controls and I try to use it in the other modules, it results in a message that the variable is not defined.
I have also experienced this working with forms and with ActiveX controls in Excel.
I have a work-around in Excel, but it would be good to know how to make the Public dimensioning work properly in Access.
For upcoming training course dates see: Pricing & availability
RE: VBA declaring Public variables for use with forms -question
Hi Kathy, thanks for your query. The trick is to declare the public variable in a standard module rather than one of the form modules:
http://bytes.com/topic/access/answers/726791-using-global-variables-access-vb-form-modules
Try setting the variable up, then loading it with a value from form 1 and passing it to a control of form 2. Let me know if you encounter any problems with this.
Hope this helps,
Anthony
|
