Login form - Remember Password

Cindy

Registered User.
Local time
Today, 01:59
Joined
Jul 3, 2014
Messages
160
Hi, my VB skills are still beginner and I need help with this please. On my Login form, I have a check box to Remember Password. How can I code this?
 
You can create a Public variable that will hold the value of the Password, if the checkbox is set to true.
 
If you mean to hold the password after the db is closed so it's there when the user starts the program, you'd have to save that checkbox value, presumably in the user table. When the program loads you can check that value and pull up the password if it's true.
 
hi, many thanks Paul. I have the below code for my login form. After confirming that the Password is correct, I assigned it to the public variable but could you advise on the code to utilise this public variable?

Public strRemember As String


Private Sub Command1_Click()

If Me.txtPassword.Value = DLookup("strPassword", "tblUser", "[UserID]
=" & Me.cmbUser.Value) Then
UserID = Me.cmbUser.Value
strRemember = Me.txtPassword.Value
DoCmd.OpenForm "ObstetricsForm"
Else
MsgBox "Invalid Password. Please Try Again", vbOKOnly, "Invalid
Entry!"
Me.txtPassword.SetFocus
End If
End Sub
 
Hi Pbaldy. Yes THAT is what I want. I'll try that. Hopefully my code works. Thanks.
 
Pbaldy my login form is unbound and the UserID has a query as rowsource but there is no option to create a rowsource for the chkRemember checkbox. Also, since the form is unbound, the table fields are not listed in the control source drop-down-arrow. Could you advise please?

My thots were to bind it to the table field [PWRemember] and then have something like:

Private Sub Command1_Click()

If Me.cmbUser.Value = DLookup("UserID", "tblUser", "[strPassword]=" &
Me.txtPassword.Value) Then
If Me.chkRemember.Value = True Then
DoCmd.OpenForm "ObstetricsForm"
End If
Else
MsgBox "You need to select a user!", vbCritical + vbExclamation,
"Required data"
End If
If IsNull(Me.txtPassword) Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Else
Me.txtPassword.Value = DLookup("strPassword", "tblUser", "[UserID]
=" & Me.cmbUser.Value)
DoCmd.OpenForm "ObstetricsForm"
End If
End Sub
 
You could add the checkbox field to the combo's row source query and check that:

If Me.cmbUser.Column(1) = True Then

though to be honest, this will end up being a relatively insecure system. I can just choose users from the combo until I find one that logs in without a password.
 
Yes I just had that discussion with a colleague and decided that it would be insecure since the userID is a combo box and some of the users (in remote locations) might at some point need to use a public machine to send in data. Many thanks Pbaldy
 
No problem. Access itself isn't all that secure anyway, but this certainly opened the doors up.
 

Users who are viewing this thread

Back
Top Bottom