Results 1 to 4 of 4
  1. #1
    puuts is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    2

    Validate password case sensitive


    Hello Gurus,

    I'm new to access vba and I'm trying to create a login form. I have already my code to login but i want to validate the password in 'case sensitive' basis. Below is only what I've got so far.

    Thanks in advance!

    Code:
    Private Sub cmdLogin_Click()
    
    Dim login_validation As Variant
    
    login_validation = DLookup("Password", "tblLogin", "Username='" & Nz(txtUsername.Value, "") & "'")
    If Nz(login_validation, "") <> Nz([txtPassword].Value, "") Then
    
        MsgBox "Incorrect Password. Please try again."
        txtUsername.Value = ""
        txtPassword.Value = ""
        txtUsername.SetFocus
    Else
      MsgBox "Hi " & txtUsername.Value & "," & vbNewLine & vbNewLine & "you have successfully login!"
      DoCmd.OpenForm "frmMain"
      
    End If
    
    
    
    End Sub

  2. #2
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    India
    Posts
    616
    Try using LCase("YourString") and UCase("YourString")
    See here for more -
    http://www.techonthenet.com/access/f...ring/ucase.php
    http://www.techonthenet.com/access/f...ring/lcase.php

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    In order to get the Access Gnomes to compare Strings on a Case Sensitive basis, you can change how comparisons are done, for that Form. At the top of the Form's Code Module change

    Option Compare Database

    to

    Option Compare Binary

    Alternatively, you could use something like

    If StrComp(String1, String2, vbBinaryCompare) = 0 Then

    But for a login Form I'd go with the Option Compare Binary.

    Linq ;0)>

  4. #4
    puuts is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    2
    Hi Missing,

    could you please set an example to my code?

Please reply to this thread with any new information or opinions.

Similar Threads

  1. How to set a case sensitive criteria for a query
    By LionelSpratt in forum Queries
    Replies: 7
    Last Post: 04-30-2013, 07:41 PM
  2. case sensitive join query
    By rbrem in forum Queries
    Replies: 5
    Last Post: 08-09-2012, 02:59 PM
  3. Textbox Case Sensitive
    By cbrsix in forum Programming
    Replies: 19
    Last Post: 06-25-2012, 10:52 AM
  4. Replies: 1
    Last Post: 03-30-2011, 02:29 PM
  5. is access case-sensitive?
    By pen in forum Programming
    Replies: 1
    Last Post: 04-07-2009, 05:13 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums