Results 1 to 6 of 6

Thread: Return to Login

  1. #1
    Join Date
    Nov 2013
    Posts
    5

    Smile Unanswered: Return to Login

    I have a login form with a password. What I want to do is if/when all other forms/reports are closed on the db, I want the login form to open. What do I have to do to make this happen. Any help would be so much appreciated.

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Here's a solution.

    1. In a Standard Module, create this function (replace Frm_Login with the name of your login form):
    Code:
    Public Function OpenLogin(FormName As String) As Long
    
        Dim frm As Form
        Dim lngCount As Long
        
        For Each frm In Forms
            If frm.Name <> FormName Then
                lngCount = lngCount + 1
            End If
        Next frm
        If lngCount = 0 Then DoCmd.OpenForm "Frm_Login"
        OpenLogin = lngCount
        
    End Function
    2. In the Class Module of every form, except the login form, add this event handler for the Close event:
    Code:
    Private Sub Form_Close()
    
        OpenLogin Me.Name
        
    End Sub
    Have a nice day!

  3. #3
    Join Date
    Nov 2013
    Posts
    5

    Smile Login

    This worked great...but I forgot one thing. I also need it to close the Switchboard when the data entry form is closed. I need just the Login form to be open. Hoping you can help me with that also. Thanks soooo much!

  4. #4
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Not sure to understand. Which version of Access do you use?
    Have a nice day!

  5. #5
    Join Date
    Nov 2013
    Posts
    5

    Smile Login

    Using Access 2007. Here's what I want to do. I have a login and if a password is entered correctly, it will take you to 'switchboard'. This is the switchboard for the front office. From here, the front office can open 'dataentry'.

    If you don't enter a password in the login, it will open 'switchboard2'. This is the switchboard for security. From here security opens 'dataentry2'.

    I don't want security to be able to make changes to the database so I've created two ways to log in with two separate forms - one is called 'dataentry' and the other is called 'dataentry2'. Both dataentry and dataentry2 are linked to the same table called 'masterlist'. So, both forms are seeing the same info but only the front office can make changes to the masterlist through 'dataentry'.

  6. #6
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    As far as I know, a Switchboard is a form, hence it is present in the Forms collection of the application when it is open. It will then be detected by the Function OpenLogin() which will close it as any other open form.
    Have a nice day!

Tags for this Thread

Posting Permissions

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