dbTalk Databases Forums  

Simple problem with addition on a form

comp.databases.ms-access comp.databases.ms-access


Discuss Simple problem with addition on a form in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Cron
 
Posts: n/a

Default Simple problem with addition on a form - 01-21-2008 , 09:37 AM






Hello,

I have 10 optional numerical fields on a form.
When I try to sum them in the control source of another input box, or
even using VB, I only get a working total if all 10 fields contain a
number.

How do I tell access to ignore fields with no number entered and also
fields containing "#Error?" so that I always get a total in the total
box?

Thanks
Ciarán

Reply With Quote
  #2  
Old   
Salad
 
Posts: n/a

Default Re: Simple problem with addition on a form - 01-21-2008 , 10:12 AM






Cron wrote:

Quote:
Hello,

I have 10 optional numerical fields on a form.
When I try to sum them in the control source of another input box, or
even using VB, I only get a working total if all 10 fields contain a
number.
You probably need to use NZ().
=NZ([fld1],0)+([fld2],0)+([fld3],0)...
Quote:
How do I tell access to ignore fields with no number entered and also
fields containing "#Error?" so that I always get a total in the total
box?
I wouldn't know. Most people would fix the #Error.

Quote:
Thanks
Ciarán
Helper
http://www.youtube.com/watch?v=j3Hf_OclE8U


Reply With Quote
  #3  
Old   
Cron
 
Posts: n/a

Default Re: Simple problem with addition on a form - 01-21-2008 , 10:28 AM



On Jan 21, 4:12 pm, Salad <o... (AT) vinegar (DOT) com> wrote:
Quote:
Cron wrote:
Hello,

I have 10 optional numerical fields on a form.
When I try to sum them in the control source of another input box, or
even using VB, I only get a working total if all 10 fields contain a
number.

You probably need to use NZ().
=NZ([fld1],0)+([fld2],0)+([fld3],0)...

How do I tell access to ignore fields with no number entered and also
fields containing "#Error?" so that I always get a total in the total
box?

I wouldn't know. Most people would fix the #Error.

Ha ha the error was actually caused by the same problem somewhere
else! I used an IIf (which I just discovered!) to fix the error and
then the Nz function to fix the totals problem. Thanks a lot for the
help guys!
Ciarán


Reply With Quote
Reply




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 On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.