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

Calculation in Form & Query

I am working on a Sales Data page of a Rent a car database where I encounter the below problem:

I have the below fields in a FORM (called Sales ) namely:
1. Odometer_Start
2. Odometer_End
3. Kilometer_Driven
4. Extra_Kilometer
5. Total_Days
6. Extra_Kilometer_Charge

and a fied in a SUBFORM (called Car_Data) namely:
1. Kilometer_Allowance (150 per day)

If a customer rent a car at 1000KM and returned it at 1100KM, he drove 100KM though he has 150 allowance. Here in the Extra_Kilometer field I don't want to appeare the negative value (-50), instead, it should be Zero value. Please help me to provide a code in Access.
Sep 27 '07 #1
1 1318
mlcampeau
296 Expert 100+
I am working on a Sales Data page of a Rent a car database where I encounter the below problem:

I have the below fields in a FORM (called Sales ) namely:
1. Odometer_Start
2. Odometer_End
3. Kilometer_Driven
4. Extra_Kilometer
5. Total_Days
6. Extra_Kilometer_Charge

and a fied in a SUBFORM (called Car_Data) namely:
1. Kilometer_Allowance (150 per day)

If a customer rent a car at 1000KM and returned it at 1100KM, he drove 100KM though he has 150 allowance. Here in the Extra_Kilometer field I don't want to appeare the negative value (-50), instead, it should be Zero value. Please help me to provide a code in Access.
You could write an iif statement in a textbox. Something like this:
=iif(([Odometer_End]-[Odometer_Start])<=[Kilometer_Allowance], 0, ([Odometer_End]-[Odometer_Start]-[Kilometer_Allowance]))
I'm not sure if this value is showing up on your main form or subform, but if it is on your main form, you will have to reference Kilometer_Allowance by referring to the subform and vice versa
Sep 27 '07 #2

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

Similar topics

4
by: Nomen Nescio | last post by:
can anyone be so kind as to look at http://www.mysolution.ws/HYPOCRITE.php and let me know why it isn't passing the form data to http://www.mysolution.ws/insertHYPOCRITES.php for the most...
5
by: Aravind | last post by:
Hi folks. I have a form, frmHistory, that has the following code for its On Open event. =-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-= Private Sub Form_Open(Cancel As Integer) ...
15
by: Pres | last post by:
I am not an experienced programmer. I do have a question regarding workday calculations. I have 3 fields. CURDATE, NUMDAYS, CALCDATE After entering the first two fields, normally the current...
4
by: lifang85 | last post by:
hi I have a large DB and the user will enter the values in the fields (1st form) and at the end of the day, there is another form (2nd) will get and compute all the values, calculate the diff...
4
by: Michiel Alsters | last post by:
Hello everybody, I hope anybody can help me. I'll try to give a brief overview of my problem. I have running a program that performs a heavy calculation. To give the user feedback what the...
7
by: eric.goforth | last post by:
Hello, I'm working with a classic asp page that calls another classic asp page. The html in my calling page looks like: <form method="post"...
4
by: vg-mail | last post by:
Hello all, I have identical design for form and report but I am getting calculation error on form and everything is OK on report. The form and report are build up on SQL statement. The...
1
by: PeterdeHoogh | last post by:
Hi, I'm new to Access and want to write a small programme for the administration of a family confection business. For that I want to use a form in which I can easily access the order information for...
23
klarae99
by: klarae99 | last post by:
In Access 2003 I am creating an Inventory Database from scratch. There are two tables (tblProductInformation and tblSubProducts) that I am trying to use in a queary to determine the number of Items...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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: 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
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,...
0
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...

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.