I also have a sub that happens on Open, but that is just to make sure that it opens to a new record.Code:Private Sub Form_AfterUpdate() Forms![MainForm]![SubForm].Requery End Sub
I also have a sub that happens on Open, but that is just to make sure that it opens to a new record.Code:Private Sub Form_AfterUpdate() Forms![MainForm]![SubForm].Requery End Sub
Is [Subform] the name of the control on the main form that contains the subform?
If so, then your command should be : Forms![MainForm]![SubForm].form.Requery
If [Subform] is not the name of the control, then you need to change it.
I tried it with the control, it popped up with an error that reads "Object doesn't support this property or method. When I look at the code the requery line is highlighted
If the names of your forms are not MainForm and SubForm which they probably should not be, then the code will not work. You need to put the actual names of your forms in those spots.
Forms![YourMainFormName]![YourSubFormName].form.Requery
THis needs to go on the AfterUpdate on YourMainForm, not the SubForm.
That's not correct. A subform is not part of the Forms! collection, and you cannot reference it that way - you have to use the [controlname].form ... method.You need to put the actual names of your forms in those spots.
And there are some advantages to that - it means you can change the subform being used "on the fly", using VBA, without having to change any code.
Usually my control name is the same as form name. Point is we using Mainform and Subform as reference, not actual names.
I am quite aware that you are using them as a reference and not actual names. I was also using them as such.