473,387 Members | 3,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Storing sessional User information using VBA

Situation:
I have a database that has users with different levels of access to the information they are allowed to view. I have addressed this issue by creating a login form that opens on startup. Behind this form is the tblUserDetails, which has login information such as: userID, password and access level (which has three levels: basic/full/admin).

Problem:
Once the user has logged in I would like to be able to retrieve their userID and access level (AccLvl) for the entire time they are using the database (ie that session). That is, controls of forms are made visible/hidden and enabled/disabled depending on the users access. Currently I am handling this by passing the userID and AccLvl values from one form to the next. In other words, I have two hidden controls on every form (txtuserID and txtAccLvl) and I populate these controls every time I open a new form. I feel this system could be improved.

Question:
Is there a way to store the userID and AccLvl information as a VBA variable? I have not used VBA to store global-sessional information like this before and I am not sure how it would work in my current multi-user networked environment (see below). Any advice would be greatly appreciated.

System Environment:
- I’m using Access 2000.
- The database is located on a network.
- It is expected that there could be up to 5 users at any one time.
- The database is split with both the front end and back end on the network. The main users of the database have copies of the front end set up on their local desktops that link to the networked back ends. However, it is possible (but not common) that more than one user at a time might access the front end which is located on the network.
Nov 22 '06 #1
10 3203
MMcCarthy
14,534 Expert Mod 8TB
To create Global variables for userID and AccLvl.

Remove the local variable definitions and instead in a Module (standard practice is to create a separate module just for this) create global variables as follows:

Global userID As String
Global AccLvl As Integer ' I assume

These variables are now available thoughout the database and will hold value passed to them unless value is changed.

Mary


Situation:
I have a database that has users with different levels of access to the information they are allowed to view. I have addressed this issue by creating a login form that opens on startup. Behind this form is the tblUserDetails, which has login information such as: userID, password and access level (which has three levels: basic/full/admin).

Problem:
Once the user has logged in I would like to be able to retrieve their userID and access level (AccLvl) for the entire time they are using the database (ie that session). That is, controls of forms are made visible/hidden and enabled/disabled depending on the users access. Currently I am handling this by passing the userID and AccLvl values from one form to the next. In other words, I have two hidden controls on every form (txtuserID and txtAccLvl) and I populate these controls every time I open a new form. I feel this system could be improved.

Question:
Is there a way to store the userID and AccLvl information as a VBA variable? I have not used VBA to store global-sessional information like this before and I am not sure how it would work in my current multi-user networked environment (see below). Any advice would be greatly appreciated.

System Environment:
- I’m using Access 2000.
- The database is located on a network.
- It is expected that there could be up to 5 users at any one time.
- The database is split with both the front end and back end on the network. The main users of the database have copies of the front end set up on their local desktops that link to the networked back ends. However, it is possible (but not common) that more than one user at a time might access the front end which is located on the network.
Nov 23 '06 #2
How do Global variables behave in Access when there is more than one user logged into the system? For example, if a restricted user logs in to the front-end and then an administrator logs into the same front-end file... are the Global variables unique to each user? (Ideally people will have different front ends but I cannot always ensure this will be the case).

thanks again


To create Global variables for userID and AccLvl.

Remove the local variable definitions and instead in a Module (standard practice is to create a separate module just for this) create global variables as follows:

Global userID As String
Global AccLvl As Integer ' I assume

These variables are now available thoughout the database and will hold value passed to them unless value is changed.

Mary
Nov 23 '06 #3
MMcCarthy
14,534 Expert Mod 8TB
How do Global variables behave in Access when there is more than one user logged into the system? For example, if a restricted user logs in to the front-end and then an administrator logs into the same front-end file... are the Global variables unique to each user? (Ideally people will have different front ends but I cannot always ensure this will be the case).

thanks again
Every time a front end is open Access creates a new instance of it. So it shouldn't be a problem.
Nov 23 '06 #4
many thanks!!

Every time a front end is open Access creates a new instance of it. So it shouldn't be a problem.
Nov 23 '06 #5
NeoPa
32,556 Expert Mod 16PB
Follow on question.
Why are such variables generally stored in a separate, stand-alone, module?
Nov 23 '06 #6
MMcCarthy
14,534 Expert Mod 8TB
Follow on question.
Why are such variables generally stored in a separate, stand-alone, module?
Simple answer.

A form module is local to the form and any variable declared publicly in the form module will only be available while that form is open. Of course any variable declared within a procedure or function is only locally declared and therefore only available to that procedure or functions.

There is no facility in VBA to declare a public variable within a procedure or function or to declare a global variable within a form module.

Also don't forget the class module where the variables declared are only available within the instance of the declaration of that class. (just thought I'd complicate the issue ;) )

Whereas a separate, stand-alone module is 'always open' or rather it is available to the whole application.

Mary
Nov 23 '06 #7
NeoPa
32,556 Expert Mod 16PB
Ah, The reason I was asking is that I have a stand-alone module which I use for globally available variables as well as general purpose code.
I thought you were indicating that I should separate these into two modules.

I know my central module is perhaps overly large, but there's no reason to split between Code and Global Variables specifically?
Nov 23 '06 #8
MMcCarthy
14,534 Expert Mod 8TB
Ah, The reason I was asking is that I have a stand-alone module which I use for globally available variables as well as general purpose code.
I thought you were indicating that I should separate these into two modules.

I know my central module is perhaps overly large, but there's no reason to split between Code and Global Variables specifically?
No, its just standard practice to split modules out.

e.g. GlobalVariables, SystemCode, MailingFunctions, etc.

Not very neat Adrian for someone who keeps giving out to me about code delimiters. :)

Mary
Nov 23 '06 #9
NeoPa
32,556 Expert Mod 16PB
I'm sorry Mary.
I'm mainly self-taught, so I don't often get to hear what standard practice is. That's why I'm asking now ;).
I generally think there are a lot of good reasons to use standard practice, even if there are no good supporting reasons. If for no better reason than clarity of understanding and communication.
Thanks for your answer.
Nov 23 '06 #10
MMcCarthy
14,534 Expert Mod 8TB
I'm sorry Mary.
I'm mainly self-taught, so I don't often get to hear what standard practice is. That's why I'm asking now ;).
I generally think there are a lot of good reasons to use standard parctice, even if there are no good supporting reasons. If for no better reason than clarity of understanding and communication.
Thanks for your answer.
You're welcome.

The thing about standard practice and naming conventions is the transparancy of applications regardless of the designer(s).

Having said that I don't always follow them myself. Particularly the naming conventions.

Mary
Nov 23 '06 #11

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

Similar topics

2
by: Francisco | last post by:
I have this problem: I have a database with information about games, and users are able to vote for them. Everytime a user votes for a game I store the unique game name into a session variable (an...
1
by: Haffi | last post by:
hi, I have a proplem creating a new user and/or adding additional information for root user in MySQL Administrator 1.0.19. When I do I get this message: error while storing the user information....
2
by: Shyam | last post by:
Hi, I wanted some advice on the following. All the users who log in to the system are created in the SQL Server. As I am not keen to store any user information on the web.config file for...
4
by: kanones | last post by:
I have some data that is been retrieved from a call to sql server stored procedure that I want to store for a period of time in a web farm architecture. I want to minimize the calls to sql server...
6
by: (PeteCresswell) | last post by:
User wants to go this route instead of storing pointers in the DB and the documents outside. Only time I tried it was with only MS Word docs - and that was a loooong time ago - and it seemed to...
3
by: ArmsTom | last post by:
I was using structures to store information read from a file. That was working fine for me, but then I read that anything stored in a structure is added to the stack and not the heap. So, I made...
9
by: KarlM | last post by:
After reading some articles regarding confuguration data I'm a bit confused. Where is the right place for storing configuration data? - XML-files? - registry? - INI-files? (from a users point...
7
by: Mike | last post by:
I have developed an application, for psyc patients.... they type in very personal information in a web form to help them work through problems in their lives. Once they enter the info, I encrypt...
2
by: Mythran | last post by:
We followed an example found on MSDN to create an encrypted FormsAuthenticationTicket and storing the ticket in a cookie. Is this the "correct" way to store the authentication ticket? We are...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.