473,748 Members | 7,142 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Subform/Main Form Calculation Problem

On my subform I have a field in the footer that totals the value of a
field. On the main form I have referenced this field. I'm using this
field in a calculation on my main form. The problem occurs when there
are no records in the subform. The field on the main form that
references the subform total field returns #Error. How can I make
this field show the total when there are records and 0 when there are
no records???

Thank you,
Chris Vettese
Nov 12 '05 #1
9 3154

A stab in the dark here, but try NZ function.

i.e.
=nz(forms![PARENTFORMNAME]![chldFormObjectN ame]![FieldReferenced],0)

Don't know if it will work, but give it a shot.

Regards,

Fraser.

ch**********@ya hoo.com (chris vettese) wrote:
On my subform I have a field in the footer that totals the value of a
field. On the main form I have referenced this field. I'm using this
field in a calculation on my main form. The problem occurs when there
are no records in the subform. The field on the main form that
references the subform total field returns #Error. How can I make
this field show the total when there are records and 0 when there are
no records???

Thank you,
Chris Vettese


Nov 12 '05 #2
Thanks for the response, unfortunatley it did not work. Any other ideas?

Regards,
Chris
"4Fraza" <fr***@clear.ne t.nz> wrote in message news:<40******* *@clear.net.nz> ...
A stab in the dark here, but try NZ function.

i.e.
=nz(forms![PARENTFORMNAME]![chldFormObjectN ame]![FieldReferenced],0)

Don't know if it will work, but give it a shot.

Regards,

Fraser.

ch**********@ya hoo.com (chris vettese) wrote:
On my subform I have a field in the footer that totals the value of a
field. On the main form I have referenced this field. I'm using this
field in a calculation on my main form. The problem occurs when there
are no records in the subform. The field on the main form that
references the subform total field returns #Error. How can I make
this field show the total when there are records and 0 when there are
no records???

Thank you,
Chris Vettese

Nov 12 '05 #3
On 30 Jan 2004 11:59:42 -0800, chris vettese wrote:
=nz(forms![PARENTFORMNAME]![chldFormObjectN ame]![FieldReferenced],0)


I believe the refference to the field may be incorrect. Try

=nz(forms![PARENTFORMNAME]![chldFormObjectN ame].Form![FieldReferenced],0)
--
Mike Storr
veraccess.com
Nov 12 '05 #4
This did not work either, is there a VB solution?

Chris
Mike Storr <st******@sympa tico.ca> wrote in message news:<9k******* *************** *******@40tude. net>...
On 30 Jan 2004 11:59:42 -0800, chris vettese wrote:
=nz(forms![PARENTFORMNAME]![chldFormObjectN ame]![FieldReferenced],0)


I believe the refference to the field may be incorrect. Try

=nz(forms![PARENTFORMNAME]![chldFormObjectN ame].Form![FieldReferenced],0)

Nov 12 '05 #5
chris vettese wrote:
=nz(forms![PARENTFORMNAME]![chldFormObjectN ame]![FieldReferenced],0)
=nz(forms![PARENTFORMNAME]![chldFormObjectN ame].Form![FieldReferenced],0)


I understand why Nz doesn't help you out--if there are no records, there
is no subform control present to refer to. No amount of Null checking
will help.

Is it possible to lift the calculation out of the subform? Into the main
form control, that is.

--
Bas Cost Budde
http://www.heuveltop.nl/BasCB

Nov 12 '05 #6
I can not bring the calculation to the main form. There has to be a
way to do this. What about HasData? Is there a way I can use this
in a form?
Chris

Bas Cost Budde <ba*@heuveltop. org> wrote in message news:<bv******* ***@news2.solco n.nl>...
chris vettese wrote:
=nz(forms![PARENTFORMNAME]![chldFormObjectN ame]![FieldReferenced],0)=nz(forms![PARENTFORMNAME]![chldFormObjectN ame].Form![FieldReferenced],0)


I understand why Nz doesn't help you out--if there are no records, there
is no subform control present to refer to. No amount of Null checking
will help.

Is it possible to lift the calculation out of the subform? Into the main
form control, that is.

Nov 12 '05 #7
On 4 Feb 2004 13:23:25 -0800, ch**********@ya hoo.com (chris vettese) wrote:
I can not bring the calculation to the main form. There has to be a
way to do this. What about HasData? Is there a way I can use this
in a form?
Chris

Bas Cost Budde <ba*@heuveltop. org> wrote in message news:<bv******* ***@news2.solco n.nl>...
chris vettese wrote:
>>>=nz(forms![PARENTFORMNAME]![chldFormObjectN ame]![FieldReferenced],0)

>>=nz(forms![PARENTFORMNAME]![chldFormObjectN ame].Form![FieldReferenced],0)


I understand why Nz doesn't help you out--if there are no records, there
is no subform control present to refer to. No amount of Null checking
will help.

Is it possible to lift the calculation out of the subform? Into the main
form control, that is.


Create a custom function that first checks for the existance of records in the subform. If records exist return the total else return 0.

Something like -

Function fGetTotal()

With Me.frmNameOfSub form.Form.Recor dsetClone
IF .RecordCount<>0 Then
fGetTotal=Me.fr mNameOfSubform. Form!NameOfTota lsControl
Else
fGetTotal=0
End IF
End With

Exit Function

Set the ControlSource of the control on your main form to =fGetTotal()

Wayne Gillespie
Gosford NSW Australia
Nov 12 '05 #8
chris vettese wrote:
I can not bring the calculation to the main form. There has to be a
way to do this. What about HasData? Is there a way I can use this
in a form?


No, it applies only during Print or Preview.

Maybe you can formulate the condition where there will be no records in
the subform, and wrap the formula on the main form control in such a test?

What is your goal? Maybe it helps if I can think myself through the
structure.
--
Bas Cost Budde
http://www.heuveltop.nl/BasCB

Nov 12 '05 #9
THANK YOU very much for everyone who posted!!!

Wayne's post provided me with the solution I needed.

Again, I appreciate everyone's time and effort.

Best Regards,
Chris vettese

Wayne Gillespie <be*****@NObest fitsoftwareSPAM .com.au> wrote in message news:<e1******* *************** **********@4ax. com>...
On 4 Feb 2004 13:23:25 -0800, ch**********@ya hoo.com (chris vettese) wrote:
I can not bring the calculation to the main form. There has to be a
way to do this. What about HasData? Is there a way I can use this
in a form?
Chris

Bas Cost Budde <ba*@heuveltop. org> wrote in message news:<bv******* ***@news2.solco n.nl>...
chris vettese wrote:

>>>=nz(forms![PARENTFORMNAME]![chldFormObjectN ame]![FieldReferenced],0)>=nz(forms![PARENTFORMNAME]![chldFormObjectN ame].Form![FieldReferenced],0)

I understand why Nz doesn't help you out--if there are no records, there
is no subform control present to refer to. No amount of Null checking
will help.

Is it possible to lift the calculation out of the subform? Into the main
form control, that is.


Create a custom function that first checks for the existance of records in the subform. If records exist return the total else return 0.

Something like -

Function fGetTotal()

With Me.frmNameOfSub form.Form.Recor dsetClone
IF .RecordCount<>0 Then
fGetTotal=Me.fr mNameOfSubform. Form!NameOfTota lsControl
Else
fGetTotal=0
End IF
End With

Exit Function

Set the ControlSource of the control on your main form to =fGetTotal()

Wayne Gillespie
Gosford NSW Australia

Nov 12 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

25
10257
by: Lyn | last post by:
Hi, I am working on a genealogy form. The only table (so far) lists everybody in the family, one record per person. Each record has an autonum ID. The parent form (frmMainForm) displays the data in each record, which includes the ID of the father and the mother (who also have records in the table). One record per form. I have a Tab Control in the form, and in one of the tabs I have a subform (sfmSiblings) in which I wish to list...
0
1217
by: CSDunn | last post by:
Hello, In an Access 2003 Project, I have a main form called ‘frmRCAddendumInputMain' that contains a subform called ‘frmRCAddendumInputSub'. The main form opens upon clicking a button from another form called ‘frmRCMain'. In frmRCAddendumInputMain, there is an unbound text box called ‘PassPermnum' that gets its value from a field called ‘Permnum' on frmRCMain. The calculation in ‘PassPermnum' is as follows;
4
7017
by: Dave Boyd | last post by:
Hi, I have two very similar forms each with a subform. The main form gets a few fields from the user and passes this back to a query that the subform is bound to. The requery is done when the user enters the last qualifying field on the main form. In one case this works fine, the subform shows the data the user wants to update -- which means showing all the data put in previously (ie showing this via the requery and the continuous...
5
5259
by: tdmailbox | last post by:
I have a form with a child form. In the child form there is a list of names that can grow quite large. On the parent form I want to display the first name from the child form. I set up a test box that is populated with the code =subfrm_media_review_sec_party.Form!first_name & " " & subfrm_media_review_sec_party.Form!last_name It works except that when I flip through the names it populates the parent form with the name of what ever...
1
2937
by: gavo | last post by:
Hello everyone! Using A2K i have a form(a) with a subform(b) and within the subform there is a continuous subform(c). in the subform (b) there is a command button used to call a public function
4
5082
by: Spencer Lee | last post by:
Hi all, I really need some helps. I created a main form("category"), which contains a subform1, "Part". Inside this subform also has contains a subform2, "Inventory". The second level of subform, "Inventory" contains the field of quantity in and out, and therefore I create a text box to do the calculation for UnitOnHand. One textbox is also prepared in subform1, "Part", to get the
9
9696
by: Ecohouse | last post by:
I have a main form with two subforms. The first subform has the child link to the main form identity key. subform1 - Master Field: SK Child Field: TrainingMasterSK The second subform has a master-child link to the first subform. subform2 - Master Field: subTrainingModule.Form!TrainingModuleTopicSK Child Field: TrainingModuleTopicSK
4
1916
meLady
by: meLady | last post by:
Hello, I have a form called feedback with a subform called feedback Options. I did some counting calculation in master form "feedback" at the bottom page. the calculation is about count the number of yes, no and null that are in the feedback Options. the problem is that when navigate to a new form the calculation of the previous form is still in and I tried many times to find a solution but I couldn't ...
1
5596
by: Bob Alston | last post by:
I have a system where many subforms are used. Often the size of the subform had to be larger than could be displayed without scrolling. I set the height of the subform to the typical height appropriate for the typical screen resolution they were using. Now some users have decided to use higher screen resolutions, up to 1280/1024. When they maximize the form, that of course works but the size of the main form control containing the...
0
8991
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9370
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9321
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9247
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6796
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4602
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4874
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3312
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2782
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.