Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    Join Date
    May 2007
    Posts
    92

    Unanswered: Create a case-sensitive account in Access

    Hi Everyone,

    Does anyone knows how to make the password case-sensitive in Access using VBA?
    I wanted to create log on account similar to the msn hotmail account where it will have the "save the username" and forget the password which the user can retrieve it own password when they forget them.

    Thank
    Last edited by StevenE; 08-14-07 at 23:29.

  2. #2
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Your post isn't really clear as to exactly what you need here, but I'm guessing that you need to be able to check to see if an entered password matches a stored password. Here's some code that accomplishes that. For demonstration purposes, a message box will popup either announcing a match or a non-match. You can, of course, replace the messageboxes with your own code. This code goes behind a command button (named ConfirmPW) that's pressed after a password is entered, but could also go behind the AfterUpdate event for the password entry textbox.

    Code:
    Private Sub ConfirmPW_Click()
    Dim i As Integer
    Dim Counter As Integer
    Counter = 0
    
    If StoredPW = EnteredPW Then
     For i = 1 To Len(StoredPW)
      If Asc(Mid(StoredPW, i)) <> Asc(Mid(EnteredPW, i)) Then
       Counter = Counter + 1
      End If
     Next
      If Counter < 1 Then
       MsgBox "Password Matches !"
      Else
       MsgBox "Password Doesn't Match !"
      End If
    Else
     MsgBox "Password Doesn't Match !"
    End If
    End Sub
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    Join Date
    May 2007
    Posts
    92

    Create a case-sensitive account in Access

    Hi Missinglinq ,

    Thank for your reply..

    Hmm.. perhap i make it more clearer of my sentence.

    I created a comboBox drop-down list of the username and password (textbox).

    For eg. Username is John. Then the password is also John. However when i type John as john , the password still can be valid. How can i make the password case sensitive in these way?

    Thank again..

  4. #4
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Missinglinq's code does that for you!
    It goes through the password letter by letter and compares the ASCII character codes of each letter.

    The ascii code for J is 74.
    The ascii code for j is 106.
    George
    Home | Blog

  5. #5
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    441
    Lets have a look at the code you're using, then, and the names of your controls.

    You could also use the StrComp function

    ? StrComp("String1", "string1",vbBinaryCompare)

    When using vbBinaryCompare, you get case sensitive comparision. If the result is 0, then it's eqaul.
    Roy-Vidar

  6. #6
    Join Date
    May 2007
    Posts
    92

    Create a case sensitive account

    Hi georgev,

    My username (EmployeeName) and password (strPassword) are stored in the table. I don't know what do put for the StoredPW and EnterPW.

  7. #7
    Join Date
    May 2007
    Posts
    92

    Hi Roy-Vidar

    My application requires a logon. The username and the password are stored in
    the access database. I want to make the username field and the password field to be
    case-sensitive. I have masked the password field (password is displayed as
    ****), but i don't know how to make it case-sensitive.

    Username in the access database is "EmployeeName"
    Password in the access database is "strPassword"

    I am not sure how to use the StringComp??

  8. #8
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Quote Originally Posted by StevenE
    My application requires a logon. The username and the password are stored in the access database.
    ....still dont understand why you would wnat to force your users to have another userid and password to rememeber.. but then again its your application

    Quote Originally Posted by StevenE
    I want to make the username field and the password field to be
    case-sensitive. I have masked the password field (password is displayed as
    ****), but i don't know how to make it case-sensitive.
    ....then have look at the option compare statement.. Im guessing you will want binary or database

    Quote Originally Posted by StevenE
    I am not sure how to use the StringComp??
    ....what does the helpfile tell you about using strcomp?
    ....or failing that WWGS... what would Google Say?
    I'd rather be riding on the Tiger 800 or the Norton

  9. #9
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    441
    Well, Access isn't case sensitive, you have to tweak that yourself, through for instance the methods suggested here.

    You say you want to do this through VBA. Missinglinq has given one suggestion, I've given another. I've also asked for the names of the form controls. Since Access doesn't have any triggers, one would need form events for this, for instance as suggested by Missinglinq - a buttons click event.
    Roy-Vidar

  10. #10
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Quote Originally Posted by StevenE
    My application requires a logon. The username and the password are stored in the access database.
    [tuneful]Schoooooool project... He's the one who knows your naaaame[/tuneful]*
    Quote Originally Posted by StevenE
    I am not sure how to use the StringComp??
    See this post

    *Points for whoever can name that tune!
    George
    Home | Blog

  11. #11
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Nice hack, Roy! I always forget about the vbBinaryCompare! Of course, I'm running a little slow today! I'm still trying to figure out the purpose of having UserName = Password.
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  12. #12
    Join Date
    May 2007
    Posts
    92

    Create a case sensitive password

    Hi everybody,

    Username in the access database is "EmployeeName"
    Password in the access database is "strPassword"

    My form controls are:

    Username = cboEmployee
    Password = txtPassword

    Private Sub cmdLogin_Click()

    'Check value of password in tblEmployees to see if this matches value chosen in combo box

    If Me.txtPassword.Value = DLookup("strPassword", "LogonTable", "[LogonID]=" & Me.cboEmployee.Value) Then

    LogonID = Me.cboEmployee.Value
    MsgBox "The UserName and Password are Valid", vbOKOnly, "Login Progress"

    This is what I put for my logon Form.. The problem is that i am still not sure how u make the txt.password case-sensitive to the
    strPassword in the database.
    Thank...

  13. #13
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    OK, Steven, now we're making some progress! I am still a little fuzzy on one point.

    You say you're going to "Check value of password in tblEmployees to see if this matches value chosen in combo box"

    But then you're comparing the entered password to a field in a table named LogonTable.

    If Me.txtPassword.Value = DLookup("strPassword", "LogonTable", "[LogonID]=" & Me.cboEmployee.Value) Then

    Which table is the password stored in?
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  14. #14
    Join Date
    May 2007
    Posts
    92

    Create a case sensitive password

    Hi Missinglinq ,

    My Logon Table consist of the LogonID, EmployeeName and strPassword..

    As for the Username = EmployeeName, I had make a drop-down comboBox list for the User to choose their own name and that is fixed. As for the strPassword, I want them to make it case-sensitive with the password the user type in it.

    Thank...

  15. #15
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    you can solve two problems with one piece of code.

    the problem that you are not discussing is that storing passwords as plaintext in a database is a bad idea. saving Hash(password) is very much safer.

    ...and back to your original problem: Hash is case-sensitive.

    this demo includes a module that will hash your password. you need only the module. you save izyHash(password) in your table. you compare izyHash(userinput) with the saved hash value.

    the demo does other things that you probably don't want: it hashes user name, has a simple reverse turing test, and imposes a 2 second delay on each password attempt just for fun.

    izy
    currently using SS 2008R2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •