A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

referring to Subform Total in main form



 
 
Thread Tools Display Modes
  #1  
Old November 3rd, 2009, 02:34 PM posted to microsoft.public.access.forms,microsoft.public.access.formscoding
Jim Franklin[_2_]
external usenet poster
 
Posts: 30
Default referring to Subform Total in main form

Hi,

This is probably very simple but has bugged me on more than one occasion. I
have a main form / continuous subform setup, where the subform contains a
control ctlFieldX bound to FieldX and a control ctlTotal in the form footer
to display the sum of FieldX. This controlsource =sum([FieldX])

On my main form, I might have a control which references the total in the
subform, with a controlsource =nz(Subform.Form!txtTotal,0)

The problem occurs when the subform does not have any related records to
display. If the AllowAdditions property of the sunform is set to True, the
main form total control correctly displays 0. However, if the AllowAdditions
property is set False, the main form total control displays #Error

Can anyone tell me if there is a simple way around this?

Thank you as always,

Jim


  #2  
Old November 3rd, 2009, 03:24 PM posted to microsoft.public.access.forms,microsoft.public.access.formscoding
Douglas J. Steele[_3_]
external usenet poster
 
Posts: 3,143
Default referring to Subform Total in main form

Try checking whether Subform.Form.RecordsetClone.RecordCount is 0:

=IIf(Subform.Form.RecordsetClone.RecordCount, Nz(Subform.Form!txtTotal,0),
0)

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Jim Franklin" wrote in message
...
Hi,

This is probably very simple but has bugged me on more than one occasion.
I have a main form / continuous subform setup, where the subform contains
a control ctlFieldX bound to FieldX and a control ctlTotal in the form
footer to display the sum of FieldX. This controlsource =sum([FieldX])

On my main form, I might have a control which references the total in the
subform, with a controlsource =nz(Subform.Form!txtTotal,0)

The problem occurs when the subform does not have any related records to
display. If the AllowAdditions property of the sunform is set to True, the
main form total control correctly displays 0. However, if the
AllowAdditions property is set False, the main form total control displays
#Error

Can anyone tell me if there is a simple way around this?

Thank you as always,

Jim



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:20 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.