Solved Force upper and lower case (1 Viewer)

markdooler

Member
Local time
Today, 03:53
Joined
Nov 25, 2020
Messages
55
Hi All

I have a DB that has a user login page.

There is a table holding all the usernames and passwords.

My issue is that it is not case sensitive.

For example, my user name is Mark.Dooler but i can log in as mark.dooler

I want to restrict this so i have to use the capitals. the code for my login page is below, apologies if its long and jumbled, im learning as im going here lol.

Thanks Mark

*******************************************

Private Sub btnLogin_Click()

Dim rs As Recordset

Set rs = CurrentDb.OpenRecordset("tblUsers", dbOpenSnapshot, dbReadOnly)

rs.FindFirst "UserName='" & Me.txtUserName & "'"

If Trim(Me.txtUserName.Value & vbNullString) = vbNullString Then
MsgBox prompt:="Username should not be left blank.", buttons:=vbInformation, title:="Username Required"
Me.txtUserName.SetFocus
Exit Sub
End If

If Trim(Me.txtPassword.Value & vbNullString) = vbNullString Then
MsgBox prompt:="Password should not be left blank.", buttons:=vbInformation, title:="Password Required"
Me.txtPassword.SetFocus
Exit Sub
End If

If rs.NoMatch = True Then
MsgBox prompt:="User Name incorrect, please retry.", buttons:=vbInformation, title:="Password Required"
Me.txtUserName.SetFocus
Exit Sub
End If

If rs!Password <> Me.txtPassword Then
MsgBox prompt:="Password incorrect, please retry.", buttons:=vbInformation, title:="Password Required"
Me.txtPassword.SetFocus
Exit Sub
End If

If Me.txtPassword = "" Then
MsgBox "You must enter a Password", [vbOKOnly]
Exit Sub
End If

TempVars("Site").Value = rs!Site.Value
TempVars("UserName").Value = Me.txtUserName.Value

If rs!Access = "Manager" And rs!JobTitle <> "Multi Site Manager" Then
DoCmd.OpenForm "frmManagerDashboard"

End If

If rs!Access = "Manager" And rs!JobTitle = "Multi Site Manager" Then
DoCmd.OpenForm "frmManagerDashboardMulti"

End If

If rs!Access = "User" And rs!JobTitle = "Workshop Controller" Then
DoCmd.OpenForm "frmWorkshopControllerDaySheet"

End If

If rs!Access = "User" And rs!JobTitle <> "Workshop Controller" Then
DoCmd.OpenForm "frmDaysheet"
End If

If rs!Access = "Admin" Then
Dim prop As Property
On Error GoTo SetProperty
Set prop = CurrentDb.CreateProperty("AllowBypassKey", dbBoolean, False)

CurrentDb.Properties.Append prop

SetProperty:
If MsgBox("Would you like to turn on the bypass key?", vbYesNo, "Allow Bypass") = vbYes Then
CurrentDb.Properties("AllowBypassKey") = True
Else
CurrentDb.Properties("AllowBypassKey") = False
End If

DoCmd.Quit

End If


DoCmd.Close acForm, Me.Name



End Sub

***************************************************
 

arnelgp

error reading drive A:
Local time
Today, 10:53
Joined
May 7, 2009
Messages
12,080
compare 2 text using StrComp(text1, text2, vbBinaryCompare).

it will return 0 if the two text are Exactly the same.
google the function for more possible results.
 

markdooler

Member
Local time
Today, 03:53
Joined
Nov 25, 2020
Messages
55
compare 2 text using StrComp(text1, text2, vbBinaryCompare).

it will return 0 if the two text are Exactly the same.
google the function for more possible results.
Thanks for that.

Worked like a charm
 

Users who are viewing this thread

Top Bottom