26c0 Sikh Philosophy Network - View Single Post - Disenabling buttons base on User
View Single Post
  #5 (permalink)  
Old 28-Jul-2006, 08:21 AM
dcash45's Avatar dcash45
Guest
 
Posts: n/a
   
   
Re: Disenabling buttons base on User

I have a user type table thats keeps the usertypeId & usertypename. I have
another that call login which links the userID & the usertypeID together. So
in the form login the code I use is .....

Sub procLogin(UserName As String, Pwd As String)
On Error GoTo LoginErrors

' Declare variables
Dim dbsConnection As Database
Dim rsUser As Recordset
Dim dbstring As String
Dim sqlString As String
Dim thisUser As String
Dim temp As Integer

' DFD 1.3 (DBU1)
' Connect to database by calling a module procedure.
Set dbsConnection = procConnectToDatabase()

' Define and open the table
sqlString = "tblLogin"
Set rsUser = dbsConnection.OpenRecordset(sqlString)

sqlString = "SELECT tblLogin.UserID, tblLogin.Username,
tblLogin.Password, tblLogin.UserTypeID" & _
" FROM tblLogin" & _
" WHERE (((tblLogin.Username)='" & UserName & "') AND
((tblLogin.Password)='" & Pwd & "'));"



' Send the SQL Query to the database connection
Set rsUser = dbsConnection.OpenRecordset(sqlString)

' if eof then user was found with that username/ password
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/information-technology/11469-disenabling-buttons-base-on-user.html
If rsUser.EOF Then
temp = MsgBox("Invalid Login.", vbExclamation, "Can't Log In")
' DFD 1.5
' close recordsets and database connection
rsUser.Close
'Call procCloseDatabase(dbsConnection)
Exit Sub

'DFD 1.6
Else
' User found so find out what type they are and display appropriate GUI
UserTypeID = rsUser!UserTypeID

' Close Login GUI
DoCmd.Close

Select Case UserTypeID

Case 1: ' Manager logged in, open Manager Switchboard GUI
DoCmd.OpenForm "frmManagerSwitchboard", , , , , , rsUser!userID
Case 2: ' Employee switchboard Logged In, open Employee switchboard GUI
DoCmd.OpenForm "frmEmployeeSwitchboard", , , , , , rsUser!userID
Case 3: ' Customer switchboard Logged In, open Customer switchboard GUI
DoCmd.OpenForm "frmCustomerSwitchboard", , , , , , rsUser!userID
Case Else: procDisplayMessage ("You are not authorized to login")

End Select
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=11469


so now after the user is login a switchboard display depending the type of
user and in this switchboard I have buttons that opening up other forms. Now
the manager switcbhoard and the employee switchboard is different but the 2
have a button that opens up the form states...now heres where I get lost. I
dont know how to enable or disenable the buttons base on the user.
Reply With Quote
 
Page generated in 0.16164 seconds with 25 queries
0