473,761 Members | 3,542 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 "txtTotalPremiu m" 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 5090
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.com wrote in message
news:92******** *************** ***********@k30 g2000hse.google groups.com...
Access 2003

I subform which lists financial transactions for a client in the main
form, which i total in a textbox named "txtTotalPremiu m" 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...@myfamilyn ame.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.com wrote in message

news:92******** *************** ***********@k30 g2000hse.google groups.com...
Access 2003
I subform which lists financial transactions for a client in the main
form, which i total in a textbox named "txtTotalPremiu m" 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.com wrote in message
news:92******** *************** ***********@k30 g2000hse.google groups.com...
Access 2003

I subform which lists financial transactions for a client in the main
form, which i total in a textbox named "txtTotalPremiu m" 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(IsNume ric(NZ([PremiumGBP],0)),[PremiumGBP],0).
Jun 27 '08 #4
On May 30, 3:50*pm, "paii, Ron" <n...@no.comwro te:
"colin spalding" <colin.mard...@ btopenworld.com wrote in message

news:92******** *************** ***********@k30 g2000hse.google groups.com...
Access 2003
I subform which lists financial transactions for a client in the main
form, which i total in a textbox named "txtTotalPremiu m" 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(IsNume ric(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.com wrote in message
news:83******** *************** ***********@m73 g2000hsh.google groups.com...
On May 30, 3:50 pm, "paii, Ron" <n...@no.comwro te:
"colin spalding" <colin.mard...@ btopenworld.com wrote in message

news:92******** *************** ***********@k30 g2000hse.google groups.com...
Access 2003
I subform which lists financial transactions for a client in the main
form, which i total in a textbox named "txtTotalPremiu m" 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(IsNume ric(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.comwro te:
"colin spalding" <colin.mard...@ btopenworld.com wrote in message

news:83******** *************** ***********@m73 g2000hsh.google groups.com...
On May 30, 3:50 pm, "paii, Ron" <n...@no.comwro te:


"colin spalding" <colin.mard...@ btopenworld.com wrote in message
news:92******** *************** ***********@k30 g2000hse.google groups.com...
Access 2003
I subform which lists financial transactions for a client in the main
form, which i total in a textbox named "txtTotalPremiu m" 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(IsNume ric(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
1940
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
2701
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 requesting a "Replace" parameter. If the user clicks OK, the report opens, but only displays #Error. When the user tries to close the report, he is next presented with the choice of halting the code in break mode or not. Regardless of his choice, the app...
1
1846
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. So instead I made the control source a function to pull the value from the function. That works. Inside the text box I simply write something like =SomeFunction(). Beautiful. Works great.
4
4291
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 I know I need to call a function that will save data but I'm not sure exactly when to call this function. I've tried two ways and both seem to have 'gotcha's':
4
2414
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
2328
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 parameters. private function somename(sender:Object, e:EventArgs) thanks.
0
1323
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
6130
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 Table. I would use the key to the Items Table from the selection the user made in the combo box. SO: User chooses an item from the combo box whose value is "3". I want to look up the ItemDescription of the Item with the Key "3" and show that...
6
5975
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 forms in the database that will use this function, so I need to be able to tell the code which form to unlock. What I have is as follows: Public Function akeyEdit()
1
4007
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 me "compile errors" and can i call the function in query? Thanks. I'd appreciate any help.
0
9377
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10136
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9989
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
9925
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
9811
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...
0
8814
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7358
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
5266
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...
3
3509
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.