473,383 Members | 1,862 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Nz Function in Control Source

Access 2003

I subform which lists financial transactions for a client in the main
form, which i total in a textbox named "txtTotalPremium" in the
subform footer with the Control Source "=Sum([PremiumGBP])"; without
quotations of course. This works fine until the subform has no
records to return in which case textbox is blank. That would be fine
except I need to use the figure in another text box on the main form
as part of another calculation. I have tried hundred different
combination of the Nz and IIf functions all to no avail. it seems to
me that the straight forward "=Nz(Sum([PremiumGBP]),0)" should do it,
but unfortunately not; whatever I do I get a blank textbox and
"#Error" and/or #Name?" in the mainform textbox, Where do I go from
here?
Jun 27 '08 #1
6 5054
Several things

Make sure your total is in the Report Footer, not the page footer

The expression you want is

=Sum(IIf(IsNull([PremiumGBP]),0,[PremiumGBP]))

HTH

Phil
"colin spalding" <co***********@btopenworld.comwrote in message
news:92**********************************@k30g2000 hse.googlegroups.com...
Access 2003

I subform which lists financial transactions for a client in the main
form, which i total in a textbox named "txtTotalPremium" in the
subform footer with the Control Source "=Sum([PremiumGBP])"; without
quotations of course. This works fine until the subform has no
records to return in which case textbox is blank. That would be fine
except I need to use the figure in another text box on the main form
as part of another calculation. I have tried hundred different
combination of the Nz and IIf functions all to no avail. it seems to
me that the straight forward "=Nz(Sum([PremiumGBP]),0)" should do it,
but unfortunately not; whatever I do I get a blank textbox and
"#Error" and/or #Name?" in the mainform textbox, Where do I go from
here?

Jun 27 '08 #2
On May 30, 11:51*am, "Phil Stanton" <p...@myfamilyname.co.ukwrote:
Several things

Make sure your total is in the Report Footer, not the page footer

The expression you want is

=Sum(IIf(IsNull([PremiumGBP]),0,[PremiumGBP]))

HTH

Phil

"colin spalding" <colin.mard...@btopenworld.comwrote in message

news:92**********************************@k30g2000 hse.googlegroups.com...
Access 2003
I subform which lists financial transactions for a client in the main
form, which i total in a textbox named "txtTotalPremium" in the
subform footer with the Control Source "=Sum([PremiumGBP])"; without
quotations of course. *This works fine until the subform has no
records to return in which case textbox is blank. *That would be fine
except I need to use the figure in another text box on the main form
as part of another calculation. *I have tried hundred different
combination of the Nz and IIf functions all to no avail. *it seems to
me that the straight forward "=Nz(Sum([PremiumGBP]),0)" should do it,
but unfortunately not; whatever I do I get a blank textbox and
"#Error" and/or #Name?" in the mainform textbox, *Where do I go from
here?- Hide quoted text -

- Show quoted text -
Thanks Phil

But still no joy. Is it because I am talking about a form not a
report?
Jun 27 '08 #3

"colin spalding" <co***********@btopenworld.comwrote in message
news:92**********************************@k30g2000 hse.googlegroups.com...
Access 2003

I subform which lists financial transactions for a client in the main
form, which i total in a textbox named "txtTotalPremium" in the
subform footer with the Control Source "=Sum([PremiumGBP])"; without
quotations of course. This works fine until the subform has no
records to return in which case textbox is blank. That would be fine
except I need to use the figure in another text box on the main form
as part of another calculation. I have tried hundred different
combination of the Nz and IIf functions all to no avail. it seems to
me that the straight forward "=Nz(Sum([PremiumGBP]),0)" should do it,
but unfortunately not; whatever I do I get a blank textbox and
"#Error" and/or #Name?" in the mainform textbox, Where do I go from
here?
=Sum(NZ([PremiumGBP],0))

NZ needs to be inside the sum otherwise you may try to sum a NULL.

You get #Name when subform is empty because [PremiumGBP] field does not
exist. You will need to check for a no data condition in the subform.

Is [PremiumGBP] a numeric field? If not you will need
=Sum(iif(IsNumeric(NZ([PremiumGBP],0)),[PremiumGBP],0).
Jun 27 '08 #4
On May 30, 3:50*pm, "paii, Ron" <n...@no.comwrote:
"colin spalding" <colin.mard...@btopenworld.comwrote in message

news:92**********************************@k30g2000 hse.googlegroups.com...
Access 2003
I subform which lists financial transactions for a client in the main
form, which i total in a textbox named "txtTotalPremium" in the
subform footer with the Control Source "=Sum([PremiumGBP])"; without
quotations of course. *This works fine until the subform has no
records to return in which case textbox is blank. *That would be fine
except I need to use the figure in another text box on the main form
as part of another calculation. *I have tried hundred different
combination of the Nz and IIf functions all to no avail. *it seems to
me that the straight forward "=Nz(Sum([PremiumGBP]),0)" should do it,
but unfortunately not; whatever I do I get a blank textbox and
"#Error" and/or #Name?" in the mainform textbox, *Where do I go from
here?

=Sum(NZ([PremiumGBP],0))

NZ needs to be inside the sum otherwise you may try to sum a NULL.

You get #Name when subform is empty because [PremiumGBP] field does not
exist. You will need to check for a no data condition in the subform.

Is [PremiumGBP] a numeric field? If not you will need
=Sum(iif(IsNumeric(NZ([PremiumGBP],0)),[PremiumGBP],0).
Thanks Ron

Yes the field [PremiumGBP] definitely exists and yes it is numeric
(assuming Currency counts as numeric). I have tried both solutions
you suggest but still no joy.
Jun 27 '08 #5

"colin spalding" <co***********@btopenworld.comwrote in message
news:83**********************************@m73g2000 hsh.googlegroups.com...
On May 30, 3:50 pm, "paii, Ron" <n...@no.comwrote:
"colin spalding" <colin.mard...@btopenworld.comwrote in message

news:92**********************************@k30g2000 hse.googlegroups.com...
Access 2003
I subform which lists financial transactions for a client in the main
form, which i total in a textbox named "txtTotalPremium" in the
subform footer with the Control Source "=Sum([PremiumGBP])"; without
quotations of course. This works fine until the subform has no
records to return in which case textbox is blank. That would be fine
except I need to use the figure in another text box on the main form
as part of another calculation. I have tried hundred different
combination of the Nz and IIf functions all to no avail. it seems to
me that the straight forward "=Nz(Sum([PremiumGBP]),0)" should do it,
but unfortunately not; whatever I do I get a blank textbox and
"#Error" and/or #Name?" in the mainform textbox, Where do I go from
here?

=Sum(NZ([PremiumGBP],0))

NZ needs to be inside the sum otherwise you may try to sum a NULL.

You get #Name when subform is empty because [PremiumGBP] field does not
exist. You will need to check for a no data condition in the subform.

Is [PremiumGBP] a numeric field? If not you will need
=Sum(iif(IsNumeric(NZ([PremiumGBP],0)),[PremiumGBP],0).
>Thanks Ron
>Yes the field [PremiumGBP] definitely exists and yes it is numeric
(assuming Currency counts as numeric). I have tried both solutions
you suggest but still no joy.
Replace your current calculation with a user function to check the status of
[PremiumGBP], I think you will find [PremiumGBP] does not exist in the
subform when it is empty.
Jun 27 '08 #6
On May 30, 7:03*pm, "paii, Ron" <n...@no.comwrote:
"colin spalding" <colin.mard...@btopenworld.comwrote in message

news:83**********************************@m73g2000 hsh.googlegroups.com...
On May 30, 3:50 pm, "paii, Ron" <n...@no.comwrote:


"colin spalding" <colin.mard...@btopenworld.comwrote in message
news:92**********************************@k30g2000 hse.googlegroups.com...
Access 2003
I subform which lists financial transactions for a client in the main
form, which i total in a textbox named "txtTotalPremium" in the
subform footer with the Control Source "=Sum([PremiumGBP])"; without
quotations of course. This works fine until the subform has no
records to return in which case textbox is blank. That would be fine
except I need to use the figure in another text box on the main form
as part of another calculation. I have tried hundred different
combination of the Nz and IIf functions all to no avail. it seems to
me that the straight forward "=Nz(Sum([PremiumGBP]),0)" should do it,
but unfortunately not; whatever I do I get a blank textbox and
"#Error" and/or #Name?" in the mainform textbox, Where do I go from
here?
=Sum(NZ([PremiumGBP],0))
NZ needs to be inside the sum otherwise you may try to sum a NULL.
You get #Name when subform is empty because [PremiumGBP] field does not
exist. You will need to check for a no data condition in the subform.
Is [PremiumGBP] a numeric field? If not you will need
=Sum(iif(IsNumeric(NZ([PremiumGBP],0)),[PremiumGBP],0).
Thanks Ron
Yes the field [PremiumGBP] definitely exists and yes it is numeric
(assuming Currency counts as numeric). *I have tried both solutions
you suggest but still no joy.

Replace your current calculation with a user function to check the status of
[PremiumGBP], I think you will find [PremiumGBP] does not exist in the
subform when it is empty.- Hide quoted text -

- Show quoted text -
I'm sorry but don't understand what a "user function" means. And if
it doesn't exist when the subform is empty, how do i solve the problem?
Jun 27 '08 #7

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

Similar topics

9
by: news.microsoft.com | last post by:
Dear all, I have to do a source code editor to implement syntax hilighted with special colors , IntelliSense function. Could anybody give me some tips or links? Thanks,
2
by: Sharon | last post by:
I've had an Access 2000 app running successfully for many months on both Windows XP and Windows 2000. Recently when my Windows 2000 users call a particular report, they get first a dialog...
1
by: Richard Hollenbeck | last post by:
I noticed I can't push a value into a text box by saying something like, "txtThisTextBox = intSomeVariable * 0.5" because I get an run-time error saying I can't assign a value to this object....
4
by: John | last post by:
Hi all, This really is quite an urgent matter. I have a page with multiple, dynamically-loaded user controls and when a user clicks on a button, the whole form is submitted. Now at this stage...
4
by: Gary Varga | last post by:
Are you getting confused between client and server? Should it be: > >Source Error: > >Line 39: >Line 40: <DIV ID=divOverview >Line 41: STYLE=CustomHeightedStyle()
3
by: Mark Kurten | last post by:
in the visual studio .NET samples that come with the product, why do javascript functions all have the parameters below. Even though, the event (like Onclick) which is calling it doesn't have any...
0
by: Frank | last post by:
Short Version of Question: Can anyone provide an example of how I should embed the ActiveX and license, and then use it in a function?
1
by: sara | last post by:
I am learning how to use simple functions to make my apps more powerful and efficient. On one screen, I want to populate field B: ItemDescription by looking up the ItemDescription in the Items...
6
by: DMUM via AccessMonster.com | last post by:
Hello I am trying to pass the name of my subform to a function/sub but I can't seem to get it to work. I am using an autokey function (ctrl E) to unlock text boxes on a subform. I have a few...
1
by: Alice | last post by:
Hi, I wrote a function in VBA, but i'm not sure how to test it to make sure that my function does what i want it to do. And how would I call it in Report using the control source? it's giving...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.