I have a form t02Payment and subform t02PaymentSub. On Mainform control T001 control T020 on the subform. What would be the exact VBA code to requery? Ive done some reading and trying, no success yet.
I have a form t02Payment and subform t02PaymentSub. On Mainform control T001 control T020 on the subform. What would be the exact VBA code to requery? Ive done some reading and trying, no success yet.
If referring to a control from the same form or subform, just use Me.ControlName notation e.g. Me.T001 ; Me.T020
From outside the form its Forms!t02Payment.T001
Slightly more complicated referencing a subform form the main form
Use Me.SubformName.Form.SubformControl e.g. Me.t02PaymentSub.Form.T020
From outside the form, use Forms!t02Payment.Form.T020
You can also refer to a control in the main form from the subform using Parent notation
See this link for more examples http://allenbrowne.com/casu-04.html
"Me.SubformName.Form.SubformControl"
Me.SubformControl.Form.ControlName ?
where subform control is the name of the main form control containing the subform and ControName is the name of the control on the subform. Unless I'm misinterpreting your meaning, your syntax order is Me > [subformName] > Form (which isn't a property of the subform, rather of the subform control) > [name of control containing subform].
Then again, your use of "subformname" might mean the subform control and subformcontrol is the control on the subform. In that case, ignore me.
Last edited by Micron; 02-11-2018 at 08:03 PM. Reason: clarification
The more we hear silence, the more we begin to think about our value in this universe.
Paraphrase of Professor Brian Cox.
Sorry - I always name the subform control to be the same as the subform name.
Micron is indeed perfectly correct in clarifying the points above
Ahh, OK. It only took one time for me to regret naming a subform control the same as the subform, or for settling for the default form wizard control names (where they are named the same as their fields). The error was "Ambiguous name detected". In other words, Access couldn't distinguish between the two same-named things. Don't remember which of those 2 issues caused the error, but it has never happened since because I don't allow duplicate names. Probably it was control/field, but when it comes to subform controls/subforms, I figure why take a chance?
That's not what I meant.
If you name a subform control the same as the subform itself, you will indeed get issues.
When you place a subform in a main form, it becomes a control of the main form.
As such it can be named using the actual subform name or any alias you like
As I normally name subforms something like fsubSomeName, I just use the actual name for that purpose.
For example:
Code:strPupil = Forms!frmStudentAttendanceMarks.fsubStudentAttendanceMarks.Form.PupilID .... strDateString = Forms!frmCalendarMonth.fsubWeeklyCalendar.Form.txtWeekStartDate
Thanks. My full VBA following your advice looks like this. Gives error "Method or data member not found"
Private Sub T001_AfterUpdate()
Me.f02PaymentSub.Form.T020.Requery
End Sub
In the main form, is the subform 'control' referred to as 'f02PaymentSub'? Check the form property sheet
Check the zeroes aren't meant to be the letter O (or vice versa)
If that doesn't fix it, please post screenshots of form & subform in both form view & design view 'labelling' the required items
Hi thanks. It is working now. I named the subform T010 in the mainform. Didn't understand when you guys actually meant that since the form in the Objects list name is f02PaymentSub. I'm happy and will probably not loose an hour again!