Create a log-in screen

DMFisher

New Member
Joined
Apr 22, 2016
Messages
35
I am looking to create a log-in screen for staff to enter their Username and Password to access a certain form.

Their log-in details are saved in a table called tbl_Staff_Name (Column 7 = Username, Column 8 = Password)
When they log-in i want them to be able to access the form Splashpage

Does anybody know the quickest / best way to do this?
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
I Currently have the following code which is working perfectly... is it now possible to have code that opens a certain form dependent on the username entered?

Public Sub Login()

On Error GoTo ErrorHandler:


If IsNull([cboUser]) = True Then 'Check UserName
MsgBox "Username is required"

ElseIf IsNull([txtPassword]) = True Then 'Check Password
MsgBox "Password is required"

Else

'Compare value of txtPassword with the saved Password in tblUser
If Me.txtPassword.Value = DLookup("Password", "tblUsers", "[UserName]='" & Me.cboUser.Value & "'") Then
strUser = Me.cboUser.Value 'Set the value of strUser declared as Global Variable
strRole = DLookup("Role", "tblUsers", "[UserName]='" & Me.cboUser.Value & "'") 'set the value of strRole declared as Global Variable
DoCmd.Close acForm, "frmLogin", acSaveNo
DoCmd.OpenForm "frmMenu", acNormal, "", "", , acNormal

Else
MsgBox "Invalid Password. Please try again.", vbOKOnly, "Invalid Password"
intLogAttempt = intLogAttempt + 1
txtPassword.SetFocus

End If

End If

'Check if the user has 3 wrong log-in attempts and close the application
If intLogAttempt = 3 Then
MsgBox "You do not have access to this database.Please contact admin." & vbCrLf & vbCrLf & _
"Application will exit.", vbCritical, "Restricted Access!"
Application.Quit
End If

ErrorHandler:


End Sub
 
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,603
Members
449,038
Latest member
Arbind kumar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top