MS Access: Refresh the contents of a subform whenever the record in the main form changes in Access 2003/XP/2000/97
Question: In Microsoft Access 2003/XP/2000/97, how do I refresh the contents of a subform whenever the record in the main form changes?
Answer: There are two ways that you can refresh the subform whenever the record in the main form changes:
Method #1 - Link the subform to the form
When you're using forms and subforms in Access, generally you link your form to your subform with one or more fields. We'll quickly explain how to do this.
In our example, we have a form called Orders that has a subform called "Order Details".
If you right-click on the subform object and select the properties, you should see that there are two subform properties called "Link Child Fields" and "Link Master Fields". This will allow you to link your form to your subform, thus allowing your subform to automatically refresh whenever you change the record in the form.
Click on the button with the three dots to the right of the property called "Link Child Fields".
The Subform Field Linker window should appear. Next, select the fields that you'll use to link your subform to your form. In this example, we've selected the OrderID fields. Click on the OK button.
Now when you return to the subform properties window, you should see the "Link Child Fields" and "Link Master Fields" properties filled in. Now, Access will be refresh your subform whenever the record in the main form changes.
Method #2 - Manually refresh the subform
If you are unable to find common fields between your form and subform, you can always place code on the "On Current" event of the form to refresh the subform.
To do this, select the properties for the form. Scroll down until you find the property called "On Current". Then click on the button with the three dots to the right of this property.
When the Choose Builder window appears, highlight Code Builder. Click on the OK button.
Next, place code on the On Current event to manually requery the subform. In our example, the subform is called "order details". Now whenever the record changes in the form, the subform should refresh itself.