473,398 Members | 2,125 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,398 software developers and data experts.

Access Levels: having different views for different logins

6
Hi all,

Im creating a database in access for a fictional sports centre. What i would like help on is having different views for different logins. So, if i typed in the managers username and password, i would be able to see ALL buttons, if i typed in an admin accounts username and password, i would only be able to see some buttons and the others have disappeared.

I know how to set things so they cant be seen:

........Visible = False or True......

but cant seem to attached it to users.

Any help?

Thanks.

Tej
Feb 13 '08 #1
3 1907
jaxjagfan
254 Expert 100+
Hi all,

Im creating a database in access for a fictional sports centre. What i would like help on is having different views for different logins. So, if i typed in the managers username and password, i would be able to see ALL buttons, if i typed in an admin accounts username and password, i would only be able to see some buttons and the others have disappeared.

I know how to set things so they cant be seen:

........Visible = False or True......

but cant seem to attached it to users.

Any help?

Thanks.

Tej
You will need a user table and a user group table. Each user will belong to a group you will establish for your app.

tblUser
UserID, Login, Name, GroupID, Password (Set format of password field to "Password" so it is displayed as "******"). Login will be their user login (IE rrabbit)

tblUserGroup
GroupID, Group

A module with a Public variable - Public iGrp as Integer.

Unbound Form - frmLogin. First form that displays in app. Has 2 textboxes (txtLogin, txtPass) and 2 command buttons(cmdOK, cmdCancel). When User enters Login, Password and Clicks Ok you will need a DLookup to ensure correct password in tblUser.

When correct password is acceptable then a second DLookup to get GroupID
from tblUser.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdLogin_Click()
  2. If Me.Pass <> Dlookup("[Password]","tblUser","[Login] ='" & Me.txtLogin & "'") Then
  3. Msgbox "Incorrect Password - Try Again!"
  4. Me.txtPass.SetFocus
  5. Exit Sub
  6. Else
  7. iGrp = Dlookup("[GroupID]","tblUser","[Login] ='" & Me.txtLogin & "'")
  8. Docmd.OpenForm "YourMenuForm"
  9. End Sub
  10.  
In the menu form you will need a function or Case statement to control what gets turned on or off according to iGrp.

Expand|Select|Wrap|Line Numbers
  1. Select Case iGrp
  2. Case 1
  3. Me.cmdOpenMgr.visible = False
  4. Case 2
  5. Me.cmdOpenMgr.visible = True
  6. End Select
  7.  
I have apps which get the Windows UserID and then looks up the group and goes from there. No login form required.

Hope this helps!
Feb 13 '08 #2
Tej21
6
You will need a user table and a user group table. Each user will belong to a group you will establish for your app.

tblUser
UserID, Login, Name, GroupID, Password (Set format of password field to "Password" so it is displayed as "******"). Login will be their user login (IE rrabbit)

tblUserGroup
GroupID, Group

A module with a Public variable - Public iGrp as Integer.

Unbound Form - frmLogin. First form that displays in app. Has 2 textboxes (txtLogin, txtPass) and 2 command buttons(cmdOK, cmdCancel). When User enters Login, Password and Clicks Ok you will need a DLookup to ensure correct password in tblUser.

When correct password is acceptable then a second DLookup to get GroupID
from tblUser.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdLogin_Click()
  2. If Me.Pass <> Dlookup("[Password]","tblUser","[Login] ='" & Me.txtLogin & "'") Then
  3. Msgbox "Incorrect Password - Try Again!"
  4. Me.txtPass.SetFocus
  5. Exit Sub
  6. Else
  7. iGrp = Dlookup("[GroupID]","tblUser","[Login] ='" & Me.txtLogin & "'")
  8. Docmd.OpenForm "YourMenuForm"
  9. End Sub
  10.  
In the menu form you will need a function or Case statement to control what gets turned on or off according to iGrp.

Expand|Select|Wrap|Line Numbers
  1. Select Case iGrp
  2. Case 1
  3. Me.cmdOpenMgr.visible = False
  4. Case 2
  5. Me.cmdOpenMgr.visible = True
  6. End Select
  7.  
I have apps which get the Windows UserID and then looks up the group and goes from there. No login form required.

Hope this helps!

Thank you for that mate. I will have a go and get back to you.

Cheers

Tej
Feb 13 '08 #3
Tej21
6
Hi jaxjagfan

Im still having some trouble. I got up to the point at which im able to login with different accounts. Here is the code:

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Private intLogonAttempts As Integer
  3.  
  4. Private Sub Form_Open(Cancel As Integer)
  5. Me.cboUser.SetFocus
  6. End Sub
  7.  
  8. Private Sub cboUser_AfterUpdate()
  9. Me.txtPassword.SetFocus
  10. End Sub
  11.  
  12. Private Sub cmdLogin_Click()
  13.  
  14.     If IsNull(Me.cboUser) Or Me.cboUser = "" Then
  15.             MsgBox "You must enter a User Name.", vbOKOnly, "Need a Username"
  16.             Me.cboUser.SetFocus
  17.         Exit Sub
  18.     End If
  19.     If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
  20.             MsgBox "You must enter a Password.", vbOKOnly, "Need a password"
  21.             Me.txtPassword.SetFocus
  22.         Exit Sub
  23.     End If
  24.  
  25.     If Me.txtPassword.Value = DLookup("password", "tblUsers", "[userID]=" & Me.cboUser.Value) Then
  26.  
  27.         myUserID = Me.cboUser.Value
  28.  
  29.         DoCmd.Close acForm, "frmLogon", acSaveNo
  30.         DoCmd.OpenForm "frmMainMenu"
  31.  
  32.         Else
  33.         MsgBox "Password Invalid.  Please Try Again", vbOKOnly, "Invalid Entry!"
  34.         Me.txtPassword.SetFocus
  35.     End If
  36. End Sub
  37.  
Ive created my main menu form which has button1, button2, button3 etc.

Ive also created similar code to what you said:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Open(Cancel As Integer)
  2.  
  3.     If accessLevelID = 1 Then
  4.     Me.button1.Visible = True
  5.     Me.button2.Visible = True
  6.  
  7.     Else
  8.     Me.button1.Visible = False
  9.     Me.button2.Visible = False
  10.  
  11.     End If
  12.  
  13. End Sub
  14.  

......right, but i cant catch what username was chosen in the drop-down menu with its access level id to get the chosen buttons displayed.

The following attributes are in tblUser:

userID
surname
firstname
accessLevelID

>>> with accessLevelID being 1 for Admin, 2 general user etc

If its not a problem, i could use some help.

Thanks

Tej
Feb 14 '08 #4

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

Similar topics

4
by: Alex | last post by:
Dear netters, We are looking to build a SQL Server database that will be hooked up to a Web server (WebLogic or a .NET). The database will house data for multiple customers, and the...
2
by: John J. Hughes II | last post by:
I am having some major problem with maintaining security for my windows application to the SQL. Currently my application access the SQL using System.Data.SqlClient and all forms use stored...
20
by: John | last post by:
Hi, I've recently upgraded from Access 97 to Access 2002 & the performance basically stinks. I have tried the following items listed below but it has only had a minor impact: 1) Upgraded Jet...
4
by: Arijit Chatterjee | last post by:
I heard that MS Access is not at all a RDBMS.But why? Only the security feature in Access is low.We can't create multiple logins or... Other than that everything is available.So why not a...
49
by: Yannick Turgeon | last post by:
Hello, We are in the process of examining our current main application. We have to do some major changes and, in the process, are questionning/validating the use of MS Access as front-end. The...
4
by: BerkshireGuy | last post by:
Our IT department wants to place our Access 2000 tables on an SQL server due to the fact the tables are quite large. With that said, can we still use the Access queries or do we have to do...
0
by: William F. Zachmann | last post by:
A web site that will run on Windows Server 2003 and IIS 6.0 needs to provide three levels of access, one for the public and two others for two levels of subscribers. This is a port of a prior site...
8
by: carriolan | last post by:
Hi I have an MS Access based application almost ready for distribution to the public and I find that even though I have compiled it into an MDE file, tables and queries can still be be imported if...
8
by: adserte | last post by:
I have a security related question. I was wondering how i can set up security so that for a table: a user can read all data in the table but only update and delete their own data (there is a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
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...
0
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...
0
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...
0
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,...
0
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...

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.