Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2005
    Posts
    31

    Exclamation Unanswered: Given the User & Correspondent Password, Show specific Form. Is this possible?

    Hello. I hope you can help me with this question. I was trying to create this login form for my database. The database has 3 major forms:

    1. ADM View

    2. Manager View

    3. Supervisor View

    One login table with the following fields:

    | LoginID | UserName | Password |
    ......1......Administrator.....adm
    ......2.........Manager........mngr
    ......3........Supervisor.......sup

    My goal was once user selects Administrator from combobox and enter Administrator's password, ADM View shows up; if Manager and Manager's password then Manager View shows up and so on...

    I looked through the forum however it only has examples for get in or get out...

  2. #2
    Join Date
    Feb 2005
    Posts
    31
    So... anyone?

  3. #3
    Join Date
    Nov 2004
    Location
    Bangor, ME USA
    Posts
    44
    It sounds to me like you want to do something like

    make an autoexec macro to load your login form automaticly when db starts.
    then add a command button to your login form (if it is not already there and in the onclick property place this code.

    Code:
    Public function Startupform(Lid as Number, Un as text, pwd as text)
    On Error goto Err_handler
    
    'With Codecontextobject
    Select Case Lid
      Case 1 
        If Un = "administrator" AND pwd = "adm" then 
          docmd.openform place_administrator_formname_here, acNormal, , , , acFormEdit, acNormal
        Else
          Msgbox "Your username or password is incorrect or doesnot match please try again"
        Endif
      Case 2
        If Un = "Manager" AND pwd = "mgr" then 
          docmd.openform place_magager_formname_here, acNormal, , , , acFormEdit, acNormal
        Else
          Msgbox "Your username or password is incorrect or doesnot match please try again"
        Endif
      Case 3
        If Un = "Supervisor" AND pwd = "sup" then 
          docmd.openform place_Supervisor_formname_here, acNormal, , , , acFormEdit, acNormal
        Else
          Msgbox "Your username or password is incorrect or doesnot match please try again"
        Endif
      Case Else
        Msgbox "No valid Login Entered -- Seek administrator of this database for assistance"
    End Select
    
    Lid = Empty
    Pwd = Empty
    '.Control_name_of_Username_Field = Empty
    '.Control_name_of_Password_Field = Empty
    
    'End With
    
    Exit_Startupform:
        Exit Function
    
    Err_Handler:
        MsgBox Err.Description
        Resume Exit_Startupform
        
    End Function
    When you place the sunction on the onclick event of the button do so like this

    =startupform([Name of control that holds the Username],[Name of control that holds Password])

    I commented out the with codecontextobject staement before the Select case but you might want to do this to clear out the login information as I have done with Lid and PWD values to be sure no one sees a password they should not have. If you wish to use this just remove the comment marks from all lines commented out.

    HTH
    Kevin

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •