vba declaring public variables

Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

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

resolvedResolved · Low Priority · Version 2007

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.

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


 

Access tip:

Insert The Current Date

To insert the current date into a Table field or Form Text box use:

Ctrl+Semi-Colon(;)

View all Access hints and tips


Server loaded in 0.15 secs.