Go Back   Access World Forums > Microsoft Access Discussion > General

Thread Tools Rate Thread Display Modes
Old 06-19-2019, 07:52 AM   #1
Join Date: Apr 2013
Posts: 258
Thanks: 67
Thanked 3 Times in 3 Posts
billgyrotech is an unknown quantity at this point
Create Login Form on Database Open


How can I create a login form that will ask for Employee Name (combo box) and password field that once correct will have a different command button on my Switchboard as to what version of the AFRs form to open?

There are AFRs versions:

AFRs1 is Administrator
AFRs2 is Clerk
AFRs3 is Technician
AFRs4 is Research

I have in place an Employees table with foreign IDs from the SecurityLevels table to determine for each employee and also there are passwords.

I have not related these 2 new tables yet and not sure how to put this all together.

I appreciate any help or guidance,

Last edited by billgyrotech; 08-05-2019 at 02:10 AM.
billgyrotech is offline   Reply With Quote
Old 06-19-2019, 08:28 AM   #2
Super Moderator
Join Date: Feb 2013
Location: UK
Posts: 11,400
Thanks: 40
Thanked 3,689 Times in 3,553 Posts
CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light
Re: Create Login Form on Database Open

1. include a quit button on your login form to exit the app if user cannot supply correct username and password

2. create a vba function along these lines in the password control afterupdate event (or have another button for the user to click after they have entered their details

private sub txtPassWord_afterUpdate()
dim userRoleID as long

if isnull(txtuserName) or isnull(txtpassWord) then
    msgbox "Please complete both fields"
    exit function
end if

userRoleID=nz(dlookup("RoleID","tblUsers","username='" & txtuserName & "' AND password='" & txtpassWord & "'"),0)
if userRoleID=0 then
    msgbox "incorrect username or password, please reenter"
    docmd.openform "frmSwitchboard",,,,,,userRoleID
    docmd.close "frmLogin"
end if

end sub
userRoleID is passed to the switchboard form as an openarg value so in your switchboard form open event you might have something like

Select Case OpenArgs
    Case 1
    Case 2
End Select
A little thanks goes a long way. If you have found this post useful, please tick the thanks button
CJ_London is offline   Reply With Quote
The Following User Says Thank You to CJ_London For This Useful Post:
billgyrotech (06-19-2019)

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Open form in another database by login anissw Forms 1 07-24-2014 06:25 PM
SQL Login X out fails to open the database with the form set to open to tmedzyk SQL Server 0 04-10-2012 12:39 PM
How to create a user login screen upon loading database Nabz-78 Forms 1 03-15-2008 10:34 AM
create login form moose Forms 1 06-01-2004 06:34 AM
Login to SQL db when open Access database sphere_monk Modules & VBA 6 10-21-2003 07:51 AM

All times are GMT -8. The time now is 10:39 AM.

Microsoft Access Help
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post

Sponsored Links

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World