markdooler
Member
- Local time
- Today, 22:56
- Joined
- Nov 25, 2020
- Messages
- 58
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
***************************************************
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
***************************************************