vba declaring public variables
The UK's Number 1 for Microsoft Office Training Add this page to your favourites/bookmarksBookmark page
 
View printable version of pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

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

replyReply Fri 23 Sep 2011, 18:42Delegate Kathy said...

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

replyReply Wed 28 Sep 2011, 13:41Trainer Anthony said...

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

 

Please browse our web site to find out more about
microsoft training access course and other Microsoft training courses.

Access tip:

Change The Default Font in Access 2003

You can change the default font in Access 2003 so that whenever you create a new database your preferred font is automatically set.

To change the default font:

1.From the menu bar select Tools.
2.Click Options.
3.Go to the Datasheet tab:
4.In the Default font section select your preferred font from the list of fonts e.g. Arial.
5.Select your preferred size from the size menu e.g. 12.
6.Click Apply.

Click on the Tables/queries tab:
1.In the Query Design font section select your preferred font from the list of fonts e.g. Arial.
2.Select your preferred size from the size menu e.g. 12.
3.Click Apply.
4.Click OK.

The default font for Access has now been changed.

View all Access hints and tips


Microsoft Certified Partner Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses Security Seal verified by visa, mastercard securecard