Results 1 to 2 of 2
  1. #1
    stu_C is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    38

    Login Screen on form

    Hi All
    I have got some code for a form login screen, I am trying to add multiple account types but really struggling any suggestions would be great, what I want is when the User_Type has been checked it takes the user to the correct for depending on their account type, The below code works fine for two accounts but struggling for multiple accounts.

    I have it set like this this:

    TABLE (login_tbl)
    Forename
    Surname
    Empl_ID
    Login_Pwd
    User_Type (Select from: Admin; Standard; View Only; Finance Only)

    FORM (frm_Login)
    tb_ID - For Empl_ID (In Table)


    tb_pwd - For Login_Pwd (In Table)
    frm1Btn - Login Button

    Code:
    Private Sub frm1Btn_Click()
    If IsNull(Me.tb_ID) Or IsNull(Me.tb_pwd) Then
    MsgBox "You must enter password and login ID.", vbOKOnly + vbInformation, "Required Data"
    Me.tb_ID.SetFocus
    Exit Sub
    End If
    
    If Me.tb_pwd.Value = DLookup("[Login_Pwd]", "login_tbl", "[Empl ID]='" & Me.tb_ID.Value & "'") Then
    If DLookup("[User_Type]", "login_tbl", "[Empl ID]='" & Me.tb_ID.Value & "'") = "Admin" Then
    DoCmd.openForm "admin_menu"
    DoCmd.Close acForm, "login", acSaveNo
    Else
    DoCmd.openForm "user_menu"
    DoCmd.Close acForm, "login", acSaveNo
    End If
    Else
    MsgBox "Password or login ID incorrect. Please Try Again", vbOKOnly + vbExclamation, "Invalid Entry!"
    Me.tb_pwd.SetFocus
    End If
    End Sub

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,974
    Crossposted at https://www.access-programmers.co.uk...d.php?t=306909 with several replies.
    Please read this article about the etiquette of crossposting https://www.excelguru.ca/content.php?184
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

Please reply to this thread with any new information or opinions.

Similar Threads

  1. VBA login screen
    By Batselot in forum Access
    Replies: 3
    Last Post: 10-21-2018, 05:01 AM
  2. LogIn Screen
    By Bongobob21 in forum Forms
    Replies: 2
    Last Post: 05-18-2015, 08:28 AM
  3. Login in form - not showing on screen
    By Sheba in forum Forms
    Replies: 2
    Last Post: 10-08-2014, 09:57 AM
  4. Replies: 3
    Last Post: 06-22-2012, 04:19 PM
  5. Replies: 4
    Last Post: 05-29-2012, 01:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums