Understanding object parent child links (1 Viewer)

got_access:]

Registered User.
Local time
Today, 01:15
Joined
Jun 15, 2018
Messages
83
Hi All,
I have a subform within a form - which I've added a calculated control (text box)
It is simply the formula avg([UnitPrice]). I've named this control "UpAverage"
But the subform is in datasheet view and displays the average prices in every row.
So I've made this control invisible.

Then in the main form I've added another control (text box) which points to that control within the subform. This now being in the main form it only displays one average value for all records in the subform.

This works great but I'm trying to understand the syntax used in the link which is either a period or an exclamation point.

The link looks like this: [frm_Subform].Form![UpAverage]

This works great - and I understand the exclamation point is a parent child link.
But I don't understand why the need for the .Form after the [frm_Subform]?

Thanks in advance
 

theDBguy

I’m here to help
Staff member
Local time
Today, 01:15
Joined
Oct 29, 2018
Messages
21,449
Hi. The [frm_Subform] part is a control, which happens to be a subform control (as opposed to a Textbox or Combobox or Command Button control). As such, a subform control has a Form property, which refers to the Source Object you assigned to this subform control. So, to access a Textbox within this Source Object form, you'll need to use the Form property of the control. Hope it makes sense...
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 09:15
Joined
Jul 9, 2003
Messages
16,271
By way of an explanation further to DB Guys excellent explanation, I draw your attention to my website where I explain sub-forms in YouTube videos...

http://www.niftyaccess.com/control-records-displayed-subform/

Here:- Northwind - Customer Products List - Nifty Access


A many-to-many relationship can be best shown in MS Access as two subforms one showing one side of the relationship and one showing the other. These videos also demonstrate the features of subforms.
 

got_access:]

Registered User.
Local time
Today, 01:15
Joined
Jun 15, 2018
Messages
83
Thanks DBguy!
I got it.


And Uncle Gizmo - love your web-site! :-]
 

theDBguy

I’m here to help
Staff member
Local time
Today, 01:15
Joined
Oct 29, 2018
Messages
21,449
Hi. You're welcome. Uncle and I were happy to assist. Cheers!
 

Users who are viewing this thread

Top Bottom