Login Help

J

jserrone

Hello,

I have a database with a logon screen, I would like to be able to open a
separate form for anyone logging in as an Admin vs someone logging in as a
User. Bellow is the following VB code used to open the WelcomeForm once they
authenticate the logon. Is there a possibility to add that anyone accessing
with Admin only would have access to the form XXXX. In the tblEmployees my
Table is setup like this where strAccess defineds if this is a User or Admin:

lngEmpID strEmpName strEmpPassword strAccess
1 joe *** User
5 Admin **** Admin

Thanks

'Check value of password in tblEmployees to see if this matches value chosen
in combo box
If Me.txtPassword.Value = DLookup("strEmpPassword", "tblEmployees", "
[lngEmpID]=" & Me.cboEmployee.Value) Then

lngEmpID = Me.cboEmployee.Value

'Close logon form and open splash screen

DoCmd.OpenForm "WelcomeForm"
DoCmd.Close acForm, "frmLogon", acSaveNo
 
T

Tom Wickerath

Hi jserrone,

You can use a Select Case statement to conditionally open one form versus
another. Something like this (aircode):

Dim UserType As String
UserType = DLookup("strAccess", "tblEmployees", "[lngEmpID]=" &
Me.cboEmployee.Value)

Select Case UserType
Case "Admin"
DoCmd.Openform "NameOfAdminForm"
Case "Else"
DoCmd.Openform "NameOfFormForRegularUsers"
End Select


You might be better off using code during the startup to identify the user's
NTUserID, instead of storing passwords in a table:

Get Login name
http://www.mvps.org/access/api/api0008.htm

You could then add a field that included the NTUserID for each user, and
determine the user type (admin vs. regular user) by matching up the
appropriate record.


Tom Wickerath
Microsoft Access MVP
https://mvp.support.microsoft.com/profile/Tom
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top