#Name? error in main form when referencing subform (1 Viewer)

MsT

Registered User.
Local time
Today, 04:57
Joined
Oct 24, 2008
Messages
14
Good morning.

I’ve added a calculated field to the subform – it sums the total from a field in the subform and works correctly.
I want to display this in the main form. I’ve used a text box there, with the formula
=[Forms]![name of subform]![name of text box in subform]!
I get the #Name? error – however it gives the correct answer if I open the database, open the subform separately, then open the name form.
I think I am missing something in my understanding of forms and subforms. Can anyone give me a clue?
(Notes: form and subform are based on tables, the two tables are linked one-to-many with referential integrity enforced. The ‘Link Master Fields’ and ‘Link Child Fields’ in the property sheet of the subform are correctly completed with the correct primary/foreign key combination. The forms were created using wizards.)
Mnay thanks
MsT
 

John Big Booty

AWF VIP
Local time
Today, 21:57
Joined
Aug 29, 2005
Messages
8,263
When you refer to a control on a sub form whilst you are on the main form, the reference will be;
Code:
Me!Subform1.Form!ControlName
Bookmark this link for future reference.
 

boblarson

Smeghead
Local time
Today, 04:57
Joined
Jan 12, 2001
Messages
32,059
If you are using it as a control source on the main form you would use

=[SubformControlNameHere].[Form]![YourControlNameHere]

You don't use Me, or the full form reference.

In fact, to easily get the correct syntax, you can use this method:
http://www.btabdevelopment.com/ts/refer2sfrms
 

MsT

Registered User.
Local time
Today, 04:57
Joined
Oct 24, 2008
Messages
14
Thanks John and Bob. Bob's method works correctly at all times no matter what's open, I'm going to go with that.

Your help is very much appreciated
 

Users who are viewing this thread

Top Bottom