Password case sensitivity in a form

G

Guest

Hi there,

I have a Table with UserID and Password, with an input mask of 'password' in
the password field.

I have created a form with 2 text boxes, UserID, Password. so the user can
input username and password.

Only problem is, when i type a password in, it is not picking up the case
sensitivity in the password field of the table.

Is there a bit of code that allows case sensitivity in a password, when
logging in using a form?

For example... If i wanted to use a password of: P455wo_rd, i want to use
exact case and special characters.

Martin
 
G

Guest

Can you please be a bit more pricise, iam new to coding in access, and not
sure where everything is
 
J

Jon Lewis

I presume that you are validating the password with some code run from your
Form. In the Code window for the form you will probably see Option Compare
Database at the very top. This needs to be changed to Option Compare Binary
in order for string comparisons to be case sensitive. If for some reason
you have no Option Compare statement then in the Code window choose General
from the left dropdown at the top of the window and Declarations from the
right dropdown and type Option Compare Binary at the cursor.

HTH
 
G

Guest

Sorry about this,

Here is my code:

Private Sub Login_Click()
' Checks entry in UserId text box, if it is null then "You must enter a
UserID" is outputted to the user
If IsNull(Me.qUserId) Then
MsgBox "You must enter a UserID"
Exit Sub

Else

' Checks entry in Password text box, if it is null then "You must enter a
valid password" is outputted to the user.
If IsNull(Me.qPassword) Then
MsgBox "You must enter a valid password"
Exit Sub

End If
End If

' Uses the DLookup function to check Username and password of the user in
"tbl_Users"
'
' If the DLookup function finds the incorrect password, it outputs "Invalid
password" to the user.
'
' If the Username and Password are correct, then the form that the DB
Administrator sets will then open for the user to input data.

If Me.qPassword.Value = DLookup("password", "tbl_Users", "UserID = '" &
Me.qUserId.Value & "'") Then

DoCmd.OpenForm "Switchboard", acNormal

Else

MsgBox "Invalid Password"

End If

' After the user has logged in the "frm_Users" will close, this is an added
security feature.
DoCmd.Close acForm, "frm_Users", acSaveNo

End Sub
 
D

Douglas J Steele

While Option Compare Binary may work, it can cause problems in other areas,
where you may not want case sensitivity.

Instead, try

If StrComp(Me.qPassword.Value, DLookup("password", "tbl_Users", "UserID = '"
& Me.qUserId.Value & "'"), 0) = 0 Then
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top