Getting #NAME? in Sunform field

G

Guest

I've tried several ways of doing a calculated field in a subform. First by
putting this calculation directly in the Control Source of the Field
properties:
=[Aircraft!CurrentHours]+[Aircraft!TTA_Variable]-[Engines!Eng_TTA_atLastMOH]

Second by writing a query and referencing that in the control source.
Query is:
SELECT Aircraft.CurrentHours+Aircraft.TTA_Variable-Engines.Eng_TTA_atLastMOH
AS TSMOH
FROM Aircraft, Engines
WHERE Aircraft.Aircraft_ID=Engines.Aircraft_ID;

when I run this in SQL it works fine.

But in either case - when I view this field in the form (it is ina subform)
I get the following #NAME?

I'm new to Access - converting from Filemaker, so this might be a simple
mistake, but searching help for #NAME? brings up nothing relevant.
 
J

John Vinson

I've tried several ways of doing a calculated field in a subform. First by
putting this calculation directly in the Control Source of the Field
properties:
=[Aircraft!CurrentHours]+[Aircraft!TTA_Variable]-[Engines!Eng_TTA_atLastMOH]

You need more brackets, unless you have fields in which the fieldname
contains exclamation points. Square brackets are used to delimit
objects such as tablenames and fieldnames; anything within the
brackets is assumed to be part of that name. Try

=[Aircraft]![CurrentHours]+[Aircraft]![TTA_Variable]-[Engines]![Eng_TTA_atLastMOH]
Second by writing a query and referencing that in the control source.
Query is:
SELECT Aircraft.CurrentHours+Aircraft.TTA_Variable-Engines.Eng_TTA_atLastMOH
AS TSMOH
FROM Aircraft, Engines
WHERE Aircraft.Aircraft_ID=Engines.Aircraft_ID;

This query will work better if you use a JOIN expression instead of a
Where:

SELECT
Aircraft.CurrentHours+Aircraft.TTA_Variable-Engines.Eng_TTA_atLastMOH
AS TSMOH
FROM Aircraft INNER JOIN Engines
ON Aircraft.Aircraft_ID=Engines.Aircraft_ID;
when I run this in SQL it works fine.

But in either case - when I view this field in the form (it is ina subform)
I get the following #NAME?

Is the control source of the subform textbox TSMOH?
I'm new to Access - converting from Filemaker, so this might be a simple
mistake, but searching help for #NAME? brings up nothing relevant.

#NAME? just means that Access cannot recognize the name of whatever
you are specifying as the control's Control Source property.

John W. Vinson[MVP]
 
S

StCyrM

Good afternoon

The general expression for forms / subforms and controls is as follows;

forms!MainForm!SubFrom.form!ControlOnSubForm

Best Regards

Maurice St-Cyr
Micro Systems Consultants, Inc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top