Open the Products_subform and view its own Property sheet.
In Record Source you should see a statement similar in format to this:
Code:
SELECT DISTINCTROW PRODUCTS.Family ,PRODUCTS.Code ,PRODUCTS.Description ,PRODUCTS.Field4 ,PRODUCTS.Field5 FROM PRODUCTS;
This need only list the fields you actually want to see displayed in the subform.
Also make sure that the subform's Filter property is blank.
In the mainform's subform control the properties;
Link Child Fields and
Link Master Fields should be left empty, since you are not restricting the record list for the subform.
Now insert the line:
Me.[Products_subform].Requery
in the AfterInsert event for the mainform. This should be all you need to ensure the subform displays an uptodate set of records.
Don't use the Refresh method because:
The Refresh method shows only changes made to records in the current set. Since the Refresh method doesn't actually requery the database, the current set won't include records that have been added or exclude records that have been deleted since the database was last requeried.
Taken from the Access help page on Refresh
======================================================
Since the subform displays a full list of products one trick you might like to use, if you haven't already, is to provide a button on the mainform that causes the mainform to jump to the same record that the subform is currently pointing to.
Create a textbox on the subform, call it, say,
txtRecNo.
Set its Countrol Source to:
=[CurrentRecord]
You can hide this field as it need not be visible.
On the mainform add a textbox and call it
txtTarget.
Set its ConrolSource to:
=[Products_subform]![txtRecNo]
Now add a command button to the mainform and call it
cmdGoToRec. In place this in its Click event add:
Private Sub cmdGotoRec_Click()
On Error GoTo Err_cmdGotoRec_Click
DoCmd.GoToRecord , , acGoTo, txtTarget
Exit_cmdGotoRec_Click:
Exit Sub
Err_cmdGotoRec_Click:
MsgBox Err.Description
Resume Exit_cmdGotoRec_Click
End Sub
Hopefully you now have a subform that displays all the fields you need to see; is updated whenever a new record is added and you can use it as a means of quickly locating a particular record for editing on the mainform.
You might also like to place the
Me.[Products_subform].Requery line in the mainform's
After Del Confirm event.
Regards
Rod