Go Back   Access World Forums > Microsoft Access Discussion > General

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 06-19-2019, 07:52 AM   #1
billgyrotech
Banned
 
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

Hello,


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,
Bill


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
CJ_London
Super Moderator
 
Join Date: Feb 2013
Location: UK
Posts: 11,024
Thanks: 40
Thanked 3,578 Times in 3,456 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

Code:
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"
else
    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

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

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 01:01 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


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