case sensitive

  • Thread starter Thread starter Deleted member 8621
  • Start date Start date
D

Deleted member 8621

Guest
I want a log in when administrative functions are needed. I created a table with user info. I can find the users password but It isn't recognizing the text case (upper / lower). I have tried docmd.findrecord but that seems to want use the record. All I want to do is verify the password is correct to include case. (I'm just testing to see if I am getting the right values with my MsgBoxs.) Here is my code.

Dim psw As String

psw = InputBox("Enter Password.", "Password Protected!!")

Set rst = CurrentDb.OpenRecordset("tblAdmin")
Do
If psw = rst.Password Then MsgBox "Wow"
MsgBox rst.password
rst.MoveNext
Loop Until rst.EOF = True


Thanks
matthew
 
Last edited by a moderator:
Matthew,

If you have a form with UserName and Password on it then
this is all of the code you need:

Code:
If IsNull(DLookUp("[Password]", "tblAdmin", "[UserName] = '" & Me.UserName & "' And " & _
                                            "[PassWord] = '" & Me.Password & "'")) Then
   MsgBox("Bad Password.")
   Exit Sub
End If

Wayne
 
Input boxes are a poor choice for what you want to do. Input boxes do not test for the "case" of your string. You can not modify the format of an input box. Create a login form and use Waynes suggestion to get you started.

HTH
 
To do a case-sensitive match in Access, an easy way is to use the StrComp() function. If you're using code on a module, I think that module must have "Option Compare Database" in the declaration.
 
Thanks

dcx693 said:
To do a case-sensitive match in Access, an easy way is to use the StrComp() function. If you're using code on a module, I think that module must have "Option Compare Database" in the declaration.


dcx693
Thanks for the code. And thanks to all for the help. It is always amazing how many ways one can accomplish things.

The following code works great. I'm using an input box to gather the password and the strcomp() function to compare the entry to my password field in a table.

Do
dbpsw = rst.Password
If StrComp(psw, dbpsw, vbBinaryCompare) = 0 Then MsgBox "equal? Yes"
rst.MoveNext
Loop Until rst.EOF = True

thanks again
matthew
 

Users who are viewing this thread

Back
Top Bottom