PDA

View Full Version : How to declare Global Variable



ganesh3084
06-16-2011, 03:12 AM
Hi all

Im creating a new project in Access 2003. In my project i have 5 forms and one login form. In login form i have userid,password and department.

I need those variables to be carried out in all forms.

So is it possible to declare those variables globally? it is possible then please assist me how to declare and where to declare those variable globally

Thanks

HiTechCoach
06-16-2011, 10:26 PM
Sounds like a multi-user database.

You need to be sure and split your Access database into application and data (click here) (http://www.hitechcoach.com/index.php?option=com_content&view=article&id=35:split-your-access-database-into-application-anddata&catid=65:split-database)

II find it best not to use global variable unless you are using a MDE/ACCDE and Access in Runtime mode. Otherwise any untrapped error will cause the global variable to clear.

I like to use hidden text boxes on my main menu/switchboard to hold the values. Another option ot to hide the log on form. Either way you can use a form refernc to get the data when you need it. Also form reference can be used in a query. You can not use a global variable directly in a query. It requires a wrapper function.

To see a a working example check out: Boiler Plate Database (http://www.hitechcoach.com/index.php?option=com_docman&task=doc_details&gid=34&Itemid=28)

Boyd Trimmell aka HiTechCoach (http://www.hitechcoach.com/)
Microsoft MVP - Access Expert