** Admin Edit - Thread split from To search record **
alright,i will try...
Another is I want to add user login form in my database,I know that there are many threads about this but I still dont understand it...I already create table name [UserConfig]
where it has the following
and a form name [frmLogin] with the following
I already insert this code
The problem im having are I dont where to put this code which to compare the level of user so that some user will be able to open all form
...and how to to make the coding for allowing certain application/form for certain user...For example,adminis trator will have access for all but the user only have access for search form....
I try this code to test to see it work or not
but when click the button nothing happen...
Sorry for asking this question again....
alright,i will try...
Another is I want to add user login form in my database,I know that there are many threads about this but I still dont understand it...I already create table name [UserConfig]
where it has the following
Code:
lngID,PK,Autonumber UserName,Text IsAdmin,Text Password,Text
Code:
cmbUserName,ComboBox txtPassword,TextBox btnLogin,Button
Code:
Private Sub btnLogin_Click()
If IsNull(Me.cmbUserName) Or Me.cmbUserName = "" Then
MsgBox "Please enter UserName", vbOKOnly, "Required"
Me.cmbUserName.SetFocus
Exit Sub
End If
If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
MsgBox "Please enter Password", vbOKOnly, "Required"
Me.txtPassword.SetFocus
Exit Sub
End If
If Me.txtPassword.Value = DLookup("Password", "UserConfig", "[lngID]=" & Me.cmbUserName.Value) Then
lngID = Me.cmbUserName.Value
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry"
Me.txtPassword.SetFocus
End If
Exit Sub
intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "You do no have access to this database.", vbCritical, "Restricted Access!"
Application.Quit
End If
Code:
If DLookup("IsAdmin", "UserConfig", "[lngID]=" & Me.cmbUserName.Value = "Yes") Then
...'Coding for allowing access to application/form(I do not know)
Else
If DLookup("IsAdmin", "UserConfig", "[lngID]=" & Me.cmbUserName.Value = "No") Then
...'Coding for allowing access to application/form(I do not know)
End If
DoCmd.OpenForm "MAIN MENU"
DoCmd.Close acForm, "frmLogin", acSaveNo
I try this code to test to see it work or not
Code:
If DLookup("IsAdmin", "UserConfig", "[lngID]=" & Me.cmbUserName.Value = "Yes") Then
MsgBox "You are a Administrator", vbOKOnly
Else
If DLookup("IsAdmin", "UserConfig", "[lngID]=" & Me.cmbUserName.Value = "No") Then
MsgBox "You are a User", vbOKOnly
Exit Sub
End If
DoCmd.OpenForm "MAIN MENU"
DoCmd.Close acForm, "frmLogin", acSaveNo
Sorry for asking this question again....
Comment