Results 1 to 5 of 5
  1. #1
    colinhen is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    Jul 2017
    Posts
    2

    I want to wait 15 seconds then open the next form, wait 15 second, open the next form

    I have an Access 2013 database. I would like to open the 1st form, wait 15 seconds close it then open the next form, wait 15 seconds close it etc etc. for around 10 different forms.

    I initially tried this using Macros eg OnTimer - 15000 and then run a Macro to Close Window, open the Next Form and then Maximize it. This worked fine but when it gets to the last form it does loop back to the first one as I wanted but then it does not jump to the second form it goes back to the last one and then runs between the first form and last form i.e. PossibleMissedHistoryCard (1st form) and SFDailyWeldPrepFinalInspections8 (last form).

    I also tried using code as below (yes some has already been commented out) but this opened the form but did not display the form correctly just one field on an imcomplete form.

    Function autoexec()
    DoCmd.OpenForm "PossibleMissedHistoryCards"
    DoCmd.Maximize
    lngtimer2 = Timer()
    'Do Until Timer() > lngtimer2 + 20
    'Loop
    'DoCmd.Close


    'DoCmd.OpenForm "SFDailyFinishturn1"
    'DoCmd.Maximize
    'lngtimer3 = Timer()
    'Do Until Timer() > lngtimer3 + 20
    'Loop
    'DoCmd.Close
    'DoCmd.OpenForm "SFConnectorsArrivingatCMM2"
    'DoCmd.Maximize
    'lngtimer4 = Timer()
    'Do Until Timer() > lngtimer4 + 20
    'Loop
    'DoCmd.Close
    'DoCmd.OpenForm "SFConnectorsDepartedCMMAwaitMilling3"
    'DoCmd.Maximize
    'lngtimer5 = Timer()
    'Do Until Timer() > lngtimer5 + 20
    'Loop
    'DoCmd.Close
    'DoCmd.OpenForm "SFDailyMilling4"
    'DoCmd.Maximize
    'lngtimer6 = Timer()
    'Do Until Timer() > lngtimer6 + 20
    'Loop
    'DoCmd.Close
    'DoCmd.OpenForm "SFDailyMillingInspection5"
    'DoCmd.Maximize
    'lngtimer7 = Timer()
    'Do Until Timer() > lngtimer7 + 20
    'Loop
    'DoCmd.Close
    'DoCmd.OpenForm "SFDailyPhosphating6"
    'DoCmd.Maximize
    'lngtimer8 = Timer()
    'Do Until Timer() > lngtimer8 + 20
    'Loop
    'DoCmd.Close
    'DoCmd.OpenForm "SFDailyWaitingonNDE7"
    'DoCmd.Maximize
    'lngtimer9 = Timer()
    'Do Until Timer() > lngtimer9 + 20
    'Loop
    'DoCmd.Close
    'DoCmd.OpenForm "SFDailyWeldPrepFinalInspections8"
    'DoCmd.Maximize
    'lngtimer10 = Timer()
    'Do Until Timer() > lngtimer10 + 20
    'Loop
    'DoCmd.Close
    'DoCmd.OpenForm "PossibleMissedHistoryCards"
    'DoCmd.Maximize
    'lngtimer11 = Timer()
    'Do Until Timer() > lngtimer11 + 20
    'Loop
    End Function

    I am not good at writing code so a simple solution would be preferred.

    Any help would be appreciated.

    Thanks

  2. #2
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Here is a function to wait:

    Code:
    Public Function Pause(NumberOfSeconds As Variant)
        On Error GoTo Error_GoTo    Dim PauseTime As Variant
        Dim Start As Variant
        Dim Elapsed As Variant
    
        PauseTime = NumberOfSeconds
        Start = Timer
        Elapsed = 0
        Do While Timer < Start + PauseTime
            Elapsed = Elapsed + 1
            If Timer = 0 Then
                ' Crossing midnight
                PauseTime = PauseTime - Elapsed
                Start = 0
                Elapsed = 0
            End If
            DoEvents
        Loop
    
    Exit_GoTo:
        On Error GoTo 0
        Exit Function
    Error_GoTo:
        Debug.Print Err.Number, Err.Description, Erl
        GoTo Exit_GoTo
    End Function
    There needs to be a way to stop this looping around if you are going from the last back to the first.

    Code:
    Do Until .... ???
    DoCmd.OpenForm "form1name"
    Call Pause(15)
    Docmd.Close
    .....
    Loop

  3. #3
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,402
    This will work and it's much like your original code. It's recursive in that it calls itself over and over (see last line of code).
    I assume you have an autoexec macro that calls this code at BOJ.

    Code:
    Option Compare Database
    Option Explicit
    
    
    Function autoexec()
    Dim lngtimer2 As Long
    DoCmd.OpenForm "PossibleMissedHistoryCards"
    DoCmd.Maximize
    lngtimer2 = Timer()
    Do Until Timer() > lngtimer2 + 20
    DoEvents
    Loop
    DoCmd.Close
    DoCmd.OpenForm "SFDailyFinishturn1"
    DoCmd.Maximize
    lngtimer2 = Timer()
    Do Until Timer() > lngtimer2 + 20
    DoEvents
    Loop
    DoCmd.Close
    DoCmd.OpenForm "SFConnectorsArrivingatCMM2"
    DoCmd.Maximize
    lngtimer2 = Timer()
    Do Until Timer() > lngtimer2 + 20
    DoEvents
    Loop
    DoCmd.Close
    DoCmd.OpenForm "SFConnectorsDepartedCMMAwaitMilling3"
    DoCmd.Maximize
    lngtimer2 = Timer()
    Do Until Timer() > lngtimer2 + 20
    DoEvents
    Loop
    DoCmd.Close
    DoCmd.OpenForm "SFDailyMilling4"
    DoCmd.Maximize
    lngtimer2 = Timer()
    Do Until Timer() > lngtimer2 + 20
    DoEvents
    Loop
    DoCmd.Close
    DoCmd.OpenForm "SFDailyMillingInspection5"
    DoCmd.Maximize
    lngtimer2 = Timer()
    Do Until Timer() > lngtimer2 + 20
    DoEvents
    Loop
    DoCmd.Close
    DoCmd.OpenForm "SFDailyPhosphating6"
    DoCmd.Maximize
    lngtimer2 = Timer()
    Do Until Timer() > lngtimer2 + 20
    DoEvents
    Loop
    DoCmd.Close
    DoCmd.OpenForm "SFDailyWaitingonNDE7"
    DoCmd.Maximize
    lngtimer2 = Timer()
    Do Until Timer() > lngtimer2 + 20
    DoEvents
    Loop
    DoCmd.Close
    DoCmd.OpenForm "SFDailyWeldPrepFinalInspections8"
    DoCmd.Maximize
    lngtimer2 = Timer()
    Do Until Timer() > lngtimer2 + 20
    DoEvents
    Loop
    DoCmd.Close
    Call autoexec
    End Function
    Last edited by davegri; 07-03-2017 at 08:37 AM. Reason: c l a r i f i c a t i o n

  4. #4
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Here is another way using a table/recordset in code.

    Enter the form name(s) in a table (tblFormNames) and set the order to be displayed using the Sequence field.
    I have the delay (variable named DelayLen) set to 3 so it doesn't take a lifetime to see the forms.
    Opening the dB starts the looping. The only way to stop the forms is to press ctl-G , then click on the Reset icon.


    Code looks like
    Code:
    Public Function Kiosk()
        Dim d As DAO.Database
        Dim r As DAO.Recordset
        Dim sSQL As String
        Dim RC As Long
        Dim lngtimer As Long
        Dim knt As Integer
        Dim DelayLen As Integer
    
        DelayLen = 3      '<<<<----- set delay
        Set d = CurrentDb
    
        sSQL = "SELECT FormName"
        sSQL = sSQL & " FROM tblFormNames"
        sSQL = sSQL & " WHERE Selected = True"
        sSQL = sSQL & " ORDER BY Sequence"
    
        Set r = d.OpenRecordset(sSQL)
        r.MoveFirst
        RC = r.RecordCount
    
        Do Until False
            '    Debug.Print r("formname")
            DoCmd.OpenForm r("formname")
            DoCmd.Maximize
            lngtimer = Timer()
            Do Until Timer() > lngtimer + DelayLen
                DoEvents
            Loop
            DoCmd.Close
    
            knt = knt + 1
            If knt = RC Then
                r.MoveFirst
                knt = 0
            Else
                r.MoveNext
            End If
        Loop
    
        r.Close
        Set r = Nothing
        Set d = Nothing
    End Function
    Attached Files Attached Files

  5. #5
    colinhen is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    Jul 2017
    Posts
    2
    Thanks very much for this. I will try this if required. I actually managed to get the db to perform the way I wanted by using macros. If I use the Close Window command but Omit the name of the Form it is working the way I want.

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

Similar Threads

  1. Replies: 3
    Last Post: 08-27-2015, 06:18 PM
  2. Replies: 2
    Last Post: 10-18-2014, 07:20 AM
  3. Replies: 5
    Last Post: 10-04-2013, 12:30 AM
  4. wait and shell
    By maxbre in forum Programming
    Replies: 19
    Last Post: 11-03-2011, 11:10 AM
  5. Open Form with instance method & wait to close?
    By GeorgeBakoyannis in forum Forms
    Replies: 1
    Last Post: 10-09-2010, 11:00 AM

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