473,395 Members | 1,996 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,395 software developers and data experts.

total in a form

20
Hi,

I would like to calculate the total on a form. But the problem is that i need it to calculate from 5 text boxes on a form, but not all this text boxes are filled out depending on a client.

E.g. one client will have 3 out of the 5 text boxes filled out while another will only have 1 out the 5. So i need to be able to work out the total, but the text boxes that aint filled out have to stay empty it cant contain a 0, zero.

what is the best way to be able to do this?
Jul 12 '07 #1
1 1392
missinglinq
3,532 Expert 2GB
You can use the Nz function to return a zero for a null value.

NullValue + 1 = Null

but

Nz(NullValue) + 1 = l

This works fine if you're adding values together, because you want an empty textbox to evealuate to 0 in your calculations. But what if you want to multiply?

10 * Nz(NullValue) = 0, because 10 x 0 = 0.

While zero is the default that Nz returns for a null or empty string, you can also set it to represent another value, using Nz(NullValue, 1).

In this case 10 * Nz(NullValue, 1) = 10, because 10 x 1 = 10.

The same would be true if you were dividing.

10 / Nz(NullValue) = 0, because, strange as it sounds, 10 / 0 = 0!

And in Access, it's illegal to divide by 0, so runtime error 11 would be thrown. Since we ususally expect that a number when not divided by anything equals itself, we can again use Nz(NullValue, 1) so that

10 / Nz(NullValue, 1) = 10 because 10/1 = 10.

You could also use Nz to return a string value. In a report, for instance, you might be reporting an agent's sales for a month, and rather than showing a blank space or a zero if he had no sales, you want it to say "No Sales" you could use

Nz(MonthlySales, "No Sales")


and on the report it would printout as "No Sales"

Good Luck!

Linq ;0)>
Jul 12 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: beavenour | last post by:
I am looking for some help creating a more universal function out of this lame attempt at javascript. I have little experience with javascript and want to be able to universalize this function. ...
4
by: James Greig | last post by:
hello people, i'm just learning javascript, could someone point me in the direction of an example of the following, or give me some clues as to how it might be done: what i would like to do...
1
by: Rajani | last post by:
Hello, I have a table(msaccess) with the structure... job_code text 6 style text 10 qty number fabrication text 65 ship_date date/time
1
by: Samir | last post by:
Here is a sample form that I just made up. I would like a somekind of script that when each button is checked or unchecked to dynamicly add or subtract the total. If anyone can help, thanks alot....
10
by: giancarlodirisioster | last post by:
Can someone help me modify this for future Usenet archival and to help me solve what I don't know? <form name="addform" method="POST" action="./submit.php"> <input type="text" name="Box 1"...
0
by: Ellen Manning | last post by:
I've got an A2K form with a subform based on a query. This query has a checkbox and an amount field and returns records if checkbox is checked. I Dsum the amount field and display on the main...
2
by: Chippy | last post by:
I am having trouble working out how to update a field on an open form with a calculation based upon calculations from other tables! For example, I have 3 tables: Diary Diary_ID: autonum,...
4
by: Rich_C | last post by:
I'm sure this is very simple, but I have very little experience with javascript -- and what I do know isn't helping me here. I have a simple form where users can enter a quantity (qty) and cost...
2
by: sammiesue | last post by:
Hi, I have form with 2 autosummed textboxes ("total" and "casinototal"). I would like to have a grand total textbox ("grandtotal") get its value from summing "total" and "casinototal", but it...
21
beacon
by: beacon | last post by:
Hello to everybody, I have a section on a form that has 10 questions, numbered 1-10, with 3 option buttons per question. Each of the option buttons have the same response (Yes, No, Don't know),...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...

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.