Results 1 to 9 of 9
  1. #1
    zozo.zead is offline Novice
    Windows 11 Access 2016
    Join Date
    Oct 2023
    Posts
    14

    Return to the user interface (login) If more than one form is opened


    Attached is a file containing a code to close Form2 if the mouse is left without moving for two minutes and the code is 100% working.
    But if another form is opened, for example Form3, it does not work on it only on Form2

    What is required is the code that closes all open forms, not just Form2, because I have more than 10 forms that can be opened.
    Attached Files Attached Files

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Google 'cycle through open forms access'
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    zozo.zead is offline Novice
    Windows 11 Access 2016
    Join Date
    Oct 2023
    Posts
    14
    Quote Originally Posted by Welshgasman View Post
    Google 'cycle through open forms access'
    i dont understand


    I want all open forms to be closed

    Whether via code (On Timer)
    Or by using the ESC button, for example

  4. #4
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,566
    The example you uploaded is not of much use.

    Normally you would have a Switchboard (Main Menu)

    Then when you want to close all forms you run code to Close the Forms and return the user to the Main Menu.
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  5. #5
    davegri's Avatar
    davegri is online now Excess Access
    Windows 11 Access 2019
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,413
    Try this code behind form2. After 2 minutes, all open forms will be closed and form1 opened.

    Code:
    Option Compare Database
    Option Explicit
    'form (module) level counter
    Private mlMins As Long
    
    
    Private Sub Command0_Click()
        DoCmd.OpenForm "Form3", acNormal
    End Sub
    
    
    Private Sub Form_Timer()
    mlMins = mlMins + 1
    If mlMins = 2 Then
        'DoCmd.Close
        Call CloseAllForms
        DoCmd.OpenForm "Form1", acNormal
    End If
    End Sub
    
    
    Public Sub ResetTimer()
        Me.TimerInterval = 0
        Me.TimerInterval = 60000
        mlMins = 0
    End Sub
    
    
    Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        ResetTimer
    End Sub
    
    
    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
        ResetTimer
    End Sub
    
    
    Private Sub CloseAllForms()
        Dim obj As AccessObject
        For Each obj In CurrentProject.AllForms
           If obj.IsLoaded Then DoCmd.Close acForm, obj.Name
        Next
    End Sub

  6. #6
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    davegri's Avatar
    davegri is online now Excess Access
    Windows 11 Access 2019
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,413
    Quote Originally Posted by Micron View Post
    duplicate thread
    Oops. I'm stepping on toes. Sorry about that.

  8. #8
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    Don't know what you mean. I was reporting a duplicate thread by the OP. Just trying to let others know about it, same as if it was cross posting.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  9. #9
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,474
    You sure you want to auto close the forms? If they are entering data on those forms, might save incomplete records. Do they have to have multiple forms open? As someone mentioned you could have a switchboard to open 1 form at a time and then they close it to get to another form, etc.

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

Similar Threads

  1. Return to the user interface (login)
    By zozo.zead in forum Access
    Replies: 5
    Last Post: 11-10-2023, 09:47 AM
  2. User Login Form remains Opened at backend!
    By cap.zadi in forum Forms
    Replies: 9
    Last Post: 07-09-2017, 05:50 AM
  3. Replies: 5
    Last Post: 01-12-2015, 03:44 PM
  4. User Login Form
    By glen in forum Forms
    Replies: 21
    Last Post: 09-17-2012, 09:09 AM
  5. Replies: 0
    Last Post: 07-07-2010, 12:57 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