Results 1 to 4 of 4
  1. #1
    tuniwes is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Nov 2015
    Posts
    43

    Requery report after edit form closes

    Hi



    I am opening an edit form from a button in my report header

    Private Sub Image133_Click()
    DoCmd.OpenForm "chase notes form", , , "ID = " & Me!ID


    End Sub

    On closing the form I can refresh the report so that it shows the changes made in the edit form with a button that has Dcmd requery on the click event

    My question is how to automatically apply the requery command once the form closes without the need for the refresh buttton?

    Thanks

    Ian

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,540
    Put the code that is used by button in the forms On Close event
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    tuniwes is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Nov 2015
    Posts
    43
    Hi Bob

    That's what I expected would work but it doesn't although the same command on the button in the report header does

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,540
    In the OnClose event of the form use:
    Code:
    Reports!ReportName.Requery
    Substitute ReportName with the name of your report

    Edit:
    If the report is closed before the form is closed, the code above will cause an error.
    you could handle that with some error code. Something like:
    Code:
    Private Sub Form_Close()   
    On Error GoTo Form_Close_Error
    
    
    Reports!YourReport.Requery
    
    
       Exit Sub
    
    
    Form_Close_Error:
        If Err.Number = 2451 Then
            Exit Sub
        Else
            MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Form_Close of VBA Document '" & Me.Name & "'"
        End If
    End Sub
    Last edited by Bob Fitz; 09-23-2018 at 01:30 AM. Reason: More Info
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

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

Similar Threads

  1. Set focus when pop up form closes
    By projectpupil7 in forum Access
    Replies: 4
    Last Post: 11-15-2014, 02:02 PM
  2. Replies: 2
    Last Post: 06-19-2013, 05:46 AM
  3. Form closes after mssage box
    By liam01752 in forum Programming
    Replies: 1
    Last Post: 12-06-2010, 03:30 PM
  4. Change to Form Closes Access
    By jbhjm in forum Forms
    Replies: 5
    Last Post: 04-22-2009, 01:04 PM
  5. Replies: 1
    Last Post: 12-09-2005, 09:16 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