VBA in my logon screen

Cozzy

Registered User.
Local time
Today, 17:02
Joined
Jun 8, 2010
Messages
29
Good Morning VBA masters,
I have another problem aarrrhhhh, right I have a login screen for a new database I am creating, I have a table called "tbl logon" with the staff members and there passwords I have got this code which works fine if I just want them to close the logon screen and open the switchboard.
but what i really want is to open different switchboards for different users, i.e. admin, manager & engineer, Any ideas

here is my original code

Code:
Private Sub Command4_Click()
'check to see if the data is entered into the Username Inbox
    If IsNull(Me.Combo0) Or Me.Combo0 = "" Then
    MsgBox "You Must enter your User Name.", vbOKOnly, "Required Data"
    Me.Combo0.SetFocus
    End If
    
'Check to see if data is entered into the password box

If IsNull(Me.Text2) Or Me.Text2 = "" Then
MsgBox "You must enter a Password", vbOKOnly, "Required Data"
Me.Text2.SetFocus
End If

    'Check value of password in tblEmployees to see if this
    'matches value chosen in combo box

If Me.Text2.Value = DLookup("password", "TBL Logon", _
"[ID]=" & Me.Combo0.Value) Then

strlogon_name = Me.Combo0.Value

'close logon screen and open splash Screen
DoCmd.Close acForm, "FRM logon", acSaveNo
DoCmd.OpenForm "FRM Switch Board"

Else
MsgBox "Invalid Password. Please Try Again", vbOKOnly, "Invalid Entry"
Me.Text2.SetFocus

End If



End Sub
 
Where do you plan to hold the different class of user information and the name of the Switchboard to open? Are you simply going to hard code it in this routine (which I do not recommend)?
 
No I was thinking that I would add a field to the logon table "class" and then maybe use a SQL statement to determine a outcome?
 
I would agree and you could have the name of the Switchboard in there as well if you wanted. I would then use a Recordset and a .FindFirst rather than the domain function to check the password. If valid you would then be on the correct record to fetch the class/switchboard value and use a Select Case structure to open the right switchboard.
 

Users who are viewing this thread

Back
Top Bottom