By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,831 Members | 1,031 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,831 IT Pros & Developers. It's quick & easy.

How do I use a AccessVBA Code Module to declare a public varible?

P: 1
What is a code module? I want my log-in to save the username so I can enter it in other forms automatically. I have been told I need to declare a public variable in a "code module". What is that, how do I do it, and is there anything special I need to know about using it?
1 Week Ago #1
Share this Question
Share on Google+
2 Replies


NeoPa
Expert Mod 15k+
P: 31,302
This is about availability. Code is stored in modules but there are Standard code modules, Object (Form/Report) code modules and Class code modules.

For data to persist and be globally accessible, as I suspect you desire, it's easiest to declare them as Public scope in a Standard code module.

As to the advice to use this technique I find that somewhat suspect. In almost all circumstances the ID you've already used to log in to Windows or your domain should be used to control access to the system. Windows has a better and more reliable way of checking you're a valid user than anything you can do in Access so it's very dangerous to take the Access approach for security. Nowadays it can even lose you your livelihood and expose you to risk personally of being prosecuted for inadequate security.

Use a system that is tried and tested. It even provides Groups for you to use that make control of security very flexible and powerful.
1 Week Ago #2

twinnyfo
Expert Mod 2.5K+
P: 3,158
This may be a bit above your level of experience (based upon your initial questions, I am assuming this), but you may want to take a look at this article on User Permissions within Access. Its security is based upon verified users logging into a secured network area. This DB simply uses that information to redirect users to appropriate menus.

It's a thick read, but could be very helpful in your situation.
1 Week Ago #3

Post your reply

Sign in to post your reply or Sign up for a free account.