Totalling Subforms

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form the has 6 sub form in it. They all show and the correct
informtion is there. In each of the sub form has a field that I would like
to total up. Not all of the subform will have information.

I thought if I put a text field in the original form with data stating:

IIf([Subform Name].[Form].[HasData],[Subform Name].[Form].[Field Name],0)

It would give me the value of the field in the subform or 0.

But it returns:

#name?

Any Ideas???
 
Hi Jeff,

Access does not recognize a Name you have used...

use the CONTROL Name, not the Field Name that the control
contains (ControlSource)

make sure you are using the NAME property in the subform
reference, not its SourceObject, which is what is displayed
in the subform control when you are in design view

Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*
 
Ok in the main form the subform is call Material Assigned the saved subform
name is Material Assigned Subform and the field name is call SumOfQty.

IIf([Material Assigned].[Form].[HasData],[Material
assigned].[Form]![SumOfQty],0)

I get a message:

'You tried to run a Visual Basic procedure to set a property or method for
an object. However, the component doesn't make the property or method for
Automation operations.'

Ok what did I do now...


strive4peace" <"strive4peace2006 at yaho said:
Hi Jeff,

Access does not recognize a Name you have used...

use the CONTROL Name, not the Field Name that the control
contains (ControlSource)

make sure you are using the NAME property in the subform
reference, not its SourceObject, which is what is displayed
in the subform control when you are in design view

Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*
I have a form the has 6 sub form in it. They all show and the correct
informtion is there. In each of the sub form has a field that I would like
to total up. Not all of the subform will have information.

I thought if I put a text field in the original form with data stating:

IIf([Subform Name].[Form].[HasData],[Subform Name].[Form].[Field Name],0)

It would give me the value of the field in the subform or 0.

But it returns:

#name?

Any Ideas???
 
Ok in the main form the subform is call Material Assigned the saved subform
name is Material Assigned Subform and the field name is call SumOfQty.

IIf([Material Assigned].[Form].[HasData],[Material
assigned].[Form]![SumOfQty],0)

I get a message:

'You tried to run a Visual Basic procedure to set a property or method for
an object. However, the component doesn't make the property or method for
Automation operations.'

Ok what did I do now...


strive4peace" <"strive4peace2006 at yaho said:
Hi Jeff,

Access does not recognize a Name you have used...

use the CONTROL Name, not the Field Name that the control
contains (ControlSource)

make sure you are using the NAME property in the subform
reference, not its SourceObject, which is what is displayed
in the subform control when you are in design view

Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*
I have a form the has 6 sub form in it. They all show and the correct
informtion is there. In each of the sub form has a field that I would like
to total up. Not all of the subform will have information.

I thought if I put a text field in the original form with data stating:

IIf([Subform Name].[Form].[HasData],[Subform Name].[Form].[Field Name],0)

It would give me the value of the field in the subform or 0.

But it returns:

#name?

Any Ideas???
 
JeffH13 said:
I have a form the has 6 sub form in it. They all show and the correct
informtion is there. In each of the sub form has a field that I would like
to total up. Not all of the subform will have information.

I thought if I put a text field in the original form with data stating:

IIf([Subform Name].[Form].[HasData],[Subform Name].[Form].[Field Name],0)

It would give me the value of the field in the subform or 0.


Aside from the potential misspelled/wrong names that Crystal
mentioned, I believe that the HasData property applies only
to reports.

In Forms, I always use:

=IIf(subform.Form.RecordSetClone.RecordCount > 0,
subform.Form.textbox, 0)
 
Thanks it works great

Marshall Barton said:
JeffH13 said:
I have a form the has 6 sub form in it. They all show and the correct
informtion is there. In each of the sub form has a field that I would like
to total up. Not all of the subform will have information.

I thought if I put a text field in the original form with data stating:

IIf([Subform Name].[Form].[HasData],[Subform Name].[Form].[Field Name],0)

It would give me the value of the field in the subform or 0.


Aside from the potential misspelled/wrong names that Crystal
mentioned, I believe that the HasData property applies only
to reports.

In Forms, I always use:

=IIf(subform.Form.RecordSetClone.RecordCount > 0,
subform.Form.textbox, 0)
 

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

Back
Top