Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Case Sensitive Password Check 1

Status
Not open for further replies.

StanJx

Programmer
Jun 2, 2016
29
LK
This is my current code for comparing passwords

If Me.txtPassword.Value = DLookup("Password", "qryUser", "[UserID]=" & Me.cmbUserName.Value) Then

But there is no case sensitive validation. Would appreciate some advise on how to add a case sensitive validation to this code.
 
I tried it with an AND function but I can't seem to get is to work. Here is what I tried out

If Me.txtPassword.Value = DLookup("Password", "qryUser", "[UserID]=" & Me.cmbUserName.Value) And StrComp(Me.txtPassword, Me.cmdUserName.Column(2),1) Then

Could you help me with the code a bit.. I would really appreciate it.
 
Step 1: use vbBinaryCompare rather than vbTextCompare. The latter is case insensitive ...
 
Tried a code like this to no effect.. Is there a mistake with my code?

If Me.txtPassword.Value = DLookup("Password", "qryUser", "[UserID]=" & Me.cmbUserName.Value) And StrComp(Me.txtPassword.Value, Me.cmbUserName.Column(2), 0) Then
 
I realized that I hadn't defined the output.. It works fine.. Just had to set the output to false..

If Me.txtPassword.Value = DLookup("Password", "qryUser", "[UserID]=" & Me.cmbUserName.Value) And StrComp(Me.txtPassword.Value, Me.cmbUserName.Column(2), 0) = False Then
 
Just for future reference, the simplest way to do this, for any Form where you want comparisons to be Case Sensitive (such as in 'log-on' Forms) is, at the top of the code window for the Form, to replace

Option Compare Database

with

Option Compare Binary

All operations comparing Strings will now be Case Sensitive, with no further syntax adjustments.

Hope this helps!

There's always more than one way to skin a cat!

All posts/responses based on Access 2003/2007
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top