refreshing or requerying a continuous form when returning to it.

slharman1

Member
Local time
Today, 13:32
Joined
Mar 8, 2021
Messages
483
I have a continuous form that I can DBL click on a record and it opens a form to edit the data in that record. How do I refresh the recordset in the continuous form whenever I come back to it (it is still open in the background while working on the main form.
Thanks
 
To simply refresh the form, you can use the Requery method. However, that would reset the record pointer to the first record. If you don't want that, we'll have to add more code.
 
Thanks.
repositioning is not a problem.
But actually I will be adding records to the recordset of the continuous form while the popup form is open. So where should I put the requery method?
Thank you
 
I would probably put it after the line that opens that form from the double-click event?
 
I would probably put it after the line that opens that form from the double-click event?
I would like it to requery after I have added more records vie the pop up. It is not really a pop up or modal form. Just another form. Will the code continue when I go back to the continuous form?
Thanks
 
I would like it to requery after I have added more records vie the pop up. It is not really a pop up or modal form. Just another form. Will the code continue when I go back to the continuous form?
Thanks
I think you have two options:

1. If you don't want the user to go back and forth between the two forms, then I would recommend using the approach both @Gasman and @Pat Hartman said. In your code to open the other form, I would use something like this:
Code:
DoCmd.OpenForm "NameOfFormB", , , , , acDialog
Me.Requery
2. If you need the user to go back and fort between the two forms, but keeping in mind the warning already mentioned about updating the same data source from multiple locations at the same time, then I would probably use something like the following in the Close event of the second form.
Code:
Forms!NameOfFormA.Requery
Hope that helps...
 
If formB is not opened as modal, the code in formA continues running after formB is opened. If formB is opened as modal, the code in formA STOPS and waits for formB to close before continuing.

You can Requery formA from formB in formB's AfterUpdate event.

However, I tell you again, it is poor practice to have two forms bound to the same table open at the same time unless one of them is modal which prevents the original form from being accessed until the modal form closes.
Can I make the second form a modal form and still update it AND the sub forms on it?
If so that might work. I am not updating the first (continuous form) it is only providing the list to open the second form.
 
Being modal does not impact whether or not a form and its subforms are updateable. All it does is prevent you from setting focus to any other object in the application without closing the modal form first.
Cool. Thanks Pat. Thank you all. You’ve taught me a lot today.
 

Users who are viewing this thread

Back
Top Bottom