473,387 Members | 1,492 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 an Access Form

4
Hello,
I've got 7 fields in a Form (monday to sunday) where you can put workinghours of an employee in. At the end I've got a "Total"-field where I want to calculate the sum of the 7 days. Where can I put a formula in to calculate this? Is it possible to do that in a form?
Thank you in advance!
Franzi
Jan 18 '08 #1
4 2230
Minion
108 Expert 100+
Hello,
I've got 7 fields in a Form (monday to sunday) where you can put workinghours of an employee in. At the end I've got a "Total"-field where I want to calculate the sum of the 7 days. Where can I put a formula in to calculate this? Is it possible to do that in a form?
Thank you in advance!
Franzi
Using a form you could put this in a number of locations. The three logical locations are:
  • In the 'Got Focus' Event of the total box
  • In the 'Current' event of the form itself
  • Attached to the 'Click' event of a command button

Once you decide on the event the code is pretty simple. Providing the datatype is set to number for all it would look similar to:
Expand|Select|Wrap|Line Numbers
  1. with me
  2. .TextTotal = .Text1 + .Text2 + .Text3 + .Text4 + .Text5 + .Text6 + .Text7
  3. end with
  4.  
Basically it will just add the values into the total box. This may or may not be bound to a column in the table itself.

Hope this helps.

- Minion -
Jan 18 '08 #2
jaxjagfan
254 Expert 100+
If you have a a total textbox that is not bound (this just displays the total).
Its ControlSource would be =text1 + text2 + text3 ...

Is there a need to actually store the total since it is a calculated value? In the event the hours gets edited for a day then you don't have to worry about recalc total.

Make the default values zero (0). Access can't handle Nulls like Excel.
Jan 18 '08 #3
Franzi
4
If you have a a total textbox that is not bound (this just displays the total).
Its ControlSource would be =text1 + text2 + text3 ...

Is there a need to actually store the total since it is a calculated value? In the event the hours gets edited for a day then you don't have to worry about recalc total.

Make the default values zero (0). Access can't handle Nulls like Excel.
Thank you, I did that (=Monday+Tuesday....). now Access doesnt calculate the sum but just puts the numbers in a row like Monday is 12, tuesaday is 3 and Access puts in total: 123 instead of 15. Do you know how that comes?
Jan 18 '08 #4
jaxjagfan
254 Expert 100+
Thank you, I did that (=Monday+Tuesday....). now Access doesnt calculate the sum but just puts the numbers in a row like Monday is 12, tuesaday is 3 and Access puts in total: 123 instead of 15. Do you know how that comes?
Because it sees the values as text and is concatenating.

Since employee time can be in partial hours (8.5, 11.75, etc)

=Cdbl(Monday) + Cdbl(Tuesday) ....

This will convert the value entered to a double and then add.

It would help to set the format of each textbox to a numeric format with a set number of decimal places.
Jan 18 '08 #5

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

Similar topics

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...
2
by: Del | last post by:
Thanks in advance for any help. I have a database that was created in Access 2000. Several users have been upgraded to Access 2003. Since upgrading to 2003 we have noticed that some of the...
1
by: cdelaney | last post by:
I have a form that I created a calculation on using 2003. The calculation works exactly like I want it to but ONLY on the first and last record. The calculation does not work/exist on records in...
3
by: Andrew Chanter | last post by:
I have an access form that contains a lot of complex computations and can take up to 5 seconds before all controls display their intended numbers. To streamline the system I wrote a little...
0
by: gavo | last post by:
Hi. using A2K; i have a form containing a continous subform. The question is, how can i call a calculation for one of the fields in the continous subform from the main form. At the moment i...
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...
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...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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?
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.