Login Form

jserrone

New member
Local time
Today, 14:42
Joined
Jul 6, 2007
Messages
8
Hello,

I have the attached database with a logon screen. I would like to be able to open a separate form for anyone logging in as an Admin. 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 defines 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
 
use the following

If Me.txtPassword.Value = DLookup("strEmpPassword", "tblEmployees", "[lngEmpID]=" & Me.cboEmployee.Value) Then

lngEmpID = Me.cboEmployee.Value

'Close logon form and open splash screen

' -------------------------------------------------------------------------

dim tmpaccess as string
tmpaccess = DLookup("strAccess, "tblEmployees", "[lngEmpID]=" & Me.cboEmployee.Value) Then

if tmpaccess="Admin"
DoCmd.OpenForm "XXXXX"
else
DoCmd.OpenForm "WelcomeForm"
end if

' -------------------------------------------------------------------------

DoCmd.Close acForm, "frmLogon", acSaveNo
 
Thanks for you help!

I tired it but had some errors, actually changed your code slightly to the following:


'Close logon form and open splash screen
Dim tmpaccess As String
tmpaccess = DLookup("strAccess", "tblEmployees", "[lngEmpID]=" & Me.cboEmployee.Value)
If tmpaccess = "Admin" Then
DoCmd.OpenForm "confirm"
Else
DoCmd.OpenForm "WelcomeForm"
End If

DoCmd.Close acForm, "frmLogon", acSaveNo
 
Not quite sure why I had a THEN statement after the DLookup, it was meant to be on the IF statement.

Glad you spotted it, next time I will be more careful before I post a reply.
 

Users who are viewing this thread

Back
Top Bottom