Access Parent Subform's Record Source (1 Viewer)

Djblois

Registered User.
Local time
Today, 11:51
Joined
Jan 26, 2009
Messages
598
I am in subform A and I am trying to change the record source in subform B (they both have the same parent form) but I keep receiving this error:


Run-time error '2455'
You entered an expression that has an invalid reference to the property form/Report


These are the two ways I tried it and receiving the error in both cases:


Code:
Forms!frmDailyCheckReport.subfrmDailyCheckReportStops.Form.RecordSource = "qryDailyCheckReportStops"


Me.Parent.subfrmDailyCheckReportStopsPostponed.Form.RecordSource = "qryDailyCheckReportStops"
 

June7

AWF VIP
Local time
Today, 10:51
Joined
Mar 9, 2014
Messages
5,488
Either should work if this is a normal form/subform and not a Navigation Form.

I always name subform container different from object it holds, like ctrDetails.
 

isladogs

MVP / VIP
Local time
Today, 19:51
Joined
Jan 14, 2017
Messages
18,247
Both look OK BUT you have used two different names for the subform control.
Which is the correct name for the subform control on the main form?

The best reference for this type of code is http://access.mvps.org/Access/forms/frm0031.htm
 

Djblois

Registered User.
Local time
Today, 11:51
Joined
Jan 26, 2009
Messages
598
They are actually 2 different subforms that I need to change and I am trying both
 

isladogs

MVP / VIP
Local time
Today, 19:51
Joined
Jan 14, 2017
Messages
18,247
Then it sounds like both subform control names may be incorrect. Unless as June suggest you have a navigation form
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 14:51
Joined
May 21, 2018
Messages
8,555
You entered an expression that has an invalid reference to the property form/Repor
Like Isladogs said the name of the subform controls are probably not the same as the source object subforms, thus the error. Click on the outside of the subform control to get its real name.

By default the subform control gets the same name as the source object (another dumb Access convention), but not always the case depending on how you add the subform control. Often it will be something like Child1, Child 2...
 

Users who are viewing this thread

Top Bottom