-
February 24th, 2011, 05:18 AM
#1
VB6 Login Need Help
my program has two user accounts - administrator and a guest
when i login as an administrator then i have the full access on the commands while if i login as a guest then only the basic commands will be availabe. here's my code:
Private Sub cmdLogin_Click()
Dim Username As String
Dim Password As String
Username = Me.txtUser.Text
Password = Me.txtPwd.Text
If Username = adoLog.Recordset("User").Value And Password = adoLog.Recordset("Password") And adoLog.Recordset("UType") = "Administrator" Then
Unload Me
frmMain.Show
ElseIf adoLog.Recordset("UType") = Guest Then
With frmMain
.Show
.cmdEdit.Enabled = False
.cmdDelete.Enabled = False
.cmdAccounts.Enabled = False
End With
ElseIf txtUser.Text = "" And txtPwd.Text = "" Then
MsgBox "Please enter your username and password!", vbOKOnly + vbCritical, "Login"
txtUser.SetFocus
Else
MsgBox "Wrong credentials!", vbOKOnly + vbCritical, "Login"
txtUser.Text = ""
txtPwd.Text = ""
txtUser.SetFocus
End If
End Sub
my problem is that when i use the guest account, the messagebox "Wrong credentials" appear and therefor can not login, but if i use the administrator account i can access the system..can anyone help me?
-
February 24th, 2011, 05:25 AM
#2
Re: VB6 Login Need Help
UType = stands for the two user accounts..please i need your help badly
-
February 24th, 2011, 07:38 AM
#3
Re: VB6 Login Need Help
It seems you are only checking one record so you will only get one valid login.
The proper way is to search the database for the user name entered and then check that record if found with the password and access level
Always use [code][/code] tags when posting code.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|