473,791 Members | 2,947 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Storing sessional User information using VBA

6 New Member
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 3247
MMcCarthy
14,534 Recognized Expert Moderator MVP
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
madereal
6 New Member
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 Recognized Expert Moderator MVP
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
madereal
6 New Member
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,579 Recognized Expert Moderator MVP
Follow on question.
Why are such variables generally stored in a separate, stand-alone, module?
Nov 23 '06 #6
MMcCarthy
14,534 Recognized Expert Moderator MVP
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,579 Recognized Expert Moderator MVP
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 Recognized Expert Moderator MVP
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, MailingFunction s, etc.

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

Mary
Nov 23 '06 #9
NeoPa
32,579 Recognized Expert Moderator MVP
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

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

Similar topics

2
1772
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 array). So if they are in a page were they already voted, they won't have the option to do so. The idea is that the session cookie lasts "forever", I don't want them voting for the same game everytime they get to the site. This isn't soo strict,...
1
4803
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. Never the less, when I close the Admin program and open it again, the changes I tryed to make are saved, (althoug the program asked me if I wanted to save changes and I said no)
2
2388
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 security considerations and I need to use SQL logins for each user, I decided to create a class CurrentUserClass (some what similar to the TTUser class in microsoft's ASP.NET sample Time Track application) with properties like Name, First Name, LastName,...
4
1316
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 as much as possible. Storing it in application cache will result the calls to be made if the users are bounced from one server to another. But is this the best resolution or is there any other methodology that I can use which will be more...
6
3200
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 me like there were performance issues at the time. How about the different types? The MS docs I would expect Access to differentiate and handle appropriately (i.e. .DOC and .XLS).. but how about ..PDF? and can I stash a .TXT document in the...
3
1553
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 a class that stores the same information. The user selects any number of records from the file when the program loads & can then make changes. The records the user selects are added to an array and changes are made to the records in that array...
9
2288
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 of view, ini-files are more comfortable to read and edit) Where should I store user specific config data? Where should I store machine specific config data?
7
1886
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 the data and store it in a MySQL database. Users can then print, edit, delete or share the information they entered with their therapist. I'm not happy storing this in the database for two reasons: (1) my host places restrictions on my database...
2
2007
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 attempting to create a web service from the web application and our goal is to have the user login to the web application and then, using the same credentials and/or authentication objects, access the web services to retrieve our data from other...
0
10207
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10154
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9993
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9029
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7537
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5430
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5558
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4109
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2913
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.