|
-
April 1st, 2001, 10:45 PM
#1
log in VB form
The code for the log in VB form is this.
public LoginSucceeded as Boolean
private Sub cmdCancel_Click()
'set the global var to false
'to denote a failed login
LoginSucceeded = false
me.Hide
End Sub
private Sub cmdOK_Click()
'check for correct password
If txtPassword = "password" then
'place code to here to pass the
'success to the calling sub
'setting a global var is the easiest
LoginSucceeded = true
me.Hide
else
MsgBox "Invalid Password, try again!", , "Login"
txtPassword.SetFocus
SendKeys "{Home}+{End}"
End If
End Sub
private Sub Form_Load()
End Sub
I want to input a databbase with user names and passwords. How would I test to see if the user name and the password are in the database so the person can log in?
-
April 2nd, 2001, 08:08 AM
#2
Re: log in VB form
In cmdOK_Click, use the following code,
dbPW is a data control associated with the table containing user names and passwords.
dbPW.Recordset.FindFirst "user='" + txtUser.Text + "'AND password ='" + txtPassword + "'"
If dbPW.Recordset.NoMatch then
oh = MsgBox("Unauthorized Login", vbCritical, "error !")
LoginSucceeded=false
else
LoginSucceeded=true
Unload frmLogin
End If
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
|