Results 1 to 3 of 3
  1. #1
    DC CS is offline Advanced Beginner
    Windows 11 Office 365
    Join Date
    Jan 2023
    Location
    Vaalpark, South Africa
    Posts
    84

    Checking Variable against table field (case sensitive)

    Good day all,
    I want to check an input from the user against a field in my table. It must be an exact match, including capital letters. I am using the below code. It works perfectly, except that when the user inputs "adm!n" instead of "Adm!n", the code does not check that the first letter is a capital "A". It accepts both "adm!n" and "Adm!n" as correct, although the lower case "a" should fail the check.

    Code:
        Private Sub ApproverCode_Exit(Cancel As Integer)    Dim dbs As DAO.Database
        Dim rs As DAO.Recordset
        Dim sql As String
        Dim approver1 As String
        Dim approverCode1 As String
        Dim isValid As Boolean
        
        approver1 = Me.Approver.Value
        approverCode1 = Me.ApproverCode.Value
        
        Set dbs = CurrentDb
        Set rs = dbs.OpenRecordset("SELECT AuthoriserCode FROM Tbl_AuthCodes WHERE AuthoriserID = '" & approver1 & "'", dbOpenSnapshot)
        
        isValid = False
        
        If Not rs.EOF Then
            rs.MoveFirst
            If rs!AuthoriserCode = approverCode1 Then
                isValid = True
            End If
        End If
        
        rs.Close
        Set rs = Nothing
        Set dbs = Nothing
    
    
        If Not isValid Then
            MsgBox "Approver code is incorrect. Please try again.", vbExclamation, "Invalid Code"
            Me.approverCode.SetFocus
        End If
    End Sub
    Any suggestions how I can achieve this?



    Thanks

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,938
    Access is not case sensitive - use the strcomp function with the parameters set to view binary. On my phone but you can Google strcomp to find out more

  3. #3
    DC CS is offline Advanced Beginner
    Windows 11 Office 365
    Join Date
    Jan 2023
    Location
    Vaalpark, South Africa
    Posts
    84
    Thanks CJ_London - This resolved the issue.

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

Similar Threads

  1. Is MAX Case sensitive?
    By TOPSie in forum Access
    Replies: 13
    Last Post: 05-22-2024, 12:50 PM
  2. Short Text field - case sensitive
    By TOPSie in forum Access
    Replies: 2
    Last Post: 01-23-2023, 10:47 AM
  3. Replies: 1
    Last Post: 08-16-2022, 12:17 AM
  4. Case Sensitive Data
    By VLPOTTER in forum Access
    Replies: 1
    Last Post: 04-28-2021, 09:31 AM
  5. Case Sensitive Inner Join
    By Rriemer in forum Queries
    Replies: 3
    Last Post: 10-13-2015, 01:24 PM

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