yes/no datatype in login form

hardik_088

Registered User.
Local time
Today, 16:50
Joined
May 31, 2011
Messages
82
Hi guys,
I have login form and table "tblUsers" with four field such as ID(Autonumber),Username (text),Password(text),AdminGroup(yes/no). I want that if username is suppose guest and AdminGroup is "yes" then my tab in ribbon should display if "no" then it should not display.

I used this following code and it is working but i display that tab in ribbon with specific username like admin. but i want to display for all user where AdminGroup data type is yes.

Code
----------------------------------
Private Sub btnLogin_Click()
If IsNull(Me.txtUserName) Then
MsgBox "You must enter a user name", vbOKOnly, "Logon Message"
Me.txtUserName.SetFocus
Exit Sub
End If
If IsNull(Me.txtPassword) Then
MsgBox "You must enter a password", vbOKOnly, "Logon Message"
Me.txtPassword.SetFocus
Exit Sub
End If
If Me.txtPassword.Value = DLookup("password", "tblUsers", "[UserName]='" & Me.txtUserName.Value & "'") Then
If Me.txtUserName = "admin" Then

isValid = True
myRibbon.InvalidateControl "tabAdmin"

End If

If Me.txtUserName = "guest" Then
isValid = True

End If



DoCmd.Close acForm, "LoginForm", acSaveNo
DoCmd.OpenForm "Welcome"


Else
MsgBox "Password Invalid. Please try again", vbOKOnly, "Invalid Entry!"
Me.txtPassword.SetFocus
End If
intAttemptsLogon = intAttemptsLogon + 1
If (intAttemptsLogon > 2) Then
MsgBox "You do not have databse access.Please contact admin", vbCritical, "Restricted Access!"
Application.Quit
End If
End Sub
-------------------------------
Thanks a lot
 

Users who are viewing this thread

Back
Top Bottom