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