Results 1 to 4 of 4
  1. #1
    NextGen is offline Novice
    Windows 8 Access 2007
    Join Date
    Apr 2019
    Posts
    4

    Delay form closing

    Is there any way to delay form closing?



    My problem is the following: I have a form that I occasionally have to alter but that form needs to update a total row (worksheet view). Then I have this code to close that form and open another:

    HTML Code:
    Private Sub Exit_Click()
    On Error GoTo Err_Exit_Click        
    
    Dim stDocName As String    
    Dim stLinkCriteria As String
    
    stDocName = "Clients"        
    stLinkCriteria = "[ID]=" & Me![ID_Client]        
    DoCmd.OpenForm stDocName, , , stLinkCriteria    
    
    Exit_Exit_Click:    
    Exit Sub
    
    Err_Exit_Click:    
    MsgBox Err.Description    
    Resume Exit_Exit_Click
    The issue is that I think that if I can delay the form closing , I can set something like
    HTML Code:
    Me.ReportField_Total.SetFocus
    to force the changes update..


    Something like:

    HTML Code:
    Something here to delay 5 seconds
    
    Me.ReportField_Total.SetFocus 'To update the form in worksheet view...
    
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    Hope this can may sense to you guys...

    Thanks!
    Last edited by pbaldy; 04-18-2019 at 07:04 PM. Reason: Cleaned up code

  2. #2
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,778
    No, doesn't really make sense. When a form closes, any unsaved records are saved, assuming there's no record violations and a cancellation by the user. Your terminology is a bit confusing as well. A form doesn't have a "worksheet" anything.
    Maybe say what you need to have happen in general terms rather than asking if it can be done a certain way. Such as,
    "I need to open form2 from form1 and pass a value from form1.txtMyText to form2.txtAnotherText on form2, but I do/don't need to save form1 edits first".

    Or we can assume I guessed and you need to do something like
    If Me.Dirty Then Me.Dirty = False
    then open form2 and pass a value using .OpenArgs of form opening method
    then close form1
    Last edited by Micron; 04-18-2019 at 08:16 PM. Reason: corrected "When a form opens" to "closes"
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    This is a form in Datasheet view? What do you mean by 'update a total row'? Just want user to see the revised calc before form closes? Issues like this is why it's best to do aggregate calcs on reports instead of forms. If form is in Datasheet view, where is the button you click?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    In addition, this statement isn't accurate:

    Quote Originally Posted by NextGen View Post
    Then I have this code to close that form and open another:
    Your code opens another form, it does not close the first, and thus doesn't save the data. You'd want DoCmd.Close with the appropriate arguments.

    FYI, I edited the first block of code. Sometimes the forum software goofs it up and puts things on the same line.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Time delay action
    By gint32 in forum Programming
    Replies: 8
    Last Post: 02-03-2019, 07:34 PM
  2. Delay working i Front End
    By Joakim N in forum SQL Server
    Replies: 2
    Last Post: 06-22-2017, 11:01 AM
  3. Delay.
    By stephen c in forum Programming
    Replies: 14
    Last Post: 05-01-2017, 03:41 PM
  4. Network delay
    By KoMiKo in forum Programming
    Replies: 2
    Last Post: 01-29-2016, 12:50 AM
  5. Delay in the result
    By markyboy in forum Forms
    Replies: 1
    Last Post: 05-25-2011, 09:19 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