473,609 Members | 1,868 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

calculate grand total time in continuous forms

59 New Member
I need help to make grand total time in continuous forms.
to calculate total work time I use following formula
=format([timeout]+1-[timein]-nz([lunch]);"short time").
but when I make grand total time in form footer (for all records) my result is error.
My grand total must be in format [hh:mm].
thanks,
Nov 14 '06 #1
17 11214
Killer42
8,435 Recognized Expert Expert
=format([timeout]+1-[timein]-nz([lunch]) ; "short time")
Can you just check something for me? I'm not certain, but I think the semicolon should be a comma.
Nov 14 '06 #2
NeoPa
32,566 Recognized Expert Moderator MVP
The Format() function returns a string value.
It doesn't matter that the characters in the string look like it may be a number - Access is not fooled.
You can't perform arithmetic of any sort on a string.

Rather than using the Format() function, try using the Format property of the TextBox instead.
Nov 14 '06 #3
MMcCarthy
14,534 Recognized Expert Moderator MVP
I need help to make grand total time in continuous forms.
to calculate total work time I use following formula
=format([timeout]+1-[timein]-nz([lunch]);"short time").
but when I make grand total time in form footer (for all records) my result is error.
My grand total must be in format [hh:mm].
thanks,
Using this formula given the values below
= Format(([timeout] + 1 - [timein] - nz([lunch],0), "short time").

'if lunch is one hour
= Format((#6:12:0 0 PM# + 1) - (#9:25:00 AM#) - Nz(#1:00:00 AM#, 0), "short time")
Result: 07:47:00

'if lunch is a null value
= Format((#6:12:0 0 PM# + 1) - (#9:25:00 AM#) - Nz(Null, 0), "short time")
Result: 08:47:00

Now to sum in the footer:

This is quite complicated.

Firstly you will need two textboxes in the footer. One to hold the sum of time called calcTime (set visible to "No") and the other to display the result called txtTotalTime. Don't set either of them to anything for the moment. This will have to be done using VBA code.

Next you need to put the following function in a module.

Expand|Select|Wrap|Line Numbers
  1.  
  2. Function totalTime(tTime As Double) As String
  3. Dim days As Integer
  4. Dim hours As Double
  5. Dim minutes As Integer
  6.  
  7.   days = Int(tTime)
  8.   Debug.Print days
  9.   hours = 24 * (tTime - days)
  10.   Debug.Print Int(hours)
  11.   minutes = (hours - Int(hours)) * 60
  12.   Debug.Print minutes
  13.  
  14.   totalTime = days & " days " & Int(hours) & " hrs " & minutes & " mins"
  15.  
  16. End Function
  17.  
  18.  
Now finally you will have to create an AfterUpdate function based on the control holding total work time value for each record on the main form.
For the example I'm calling it totalWorkTime as I don't know what you've named it.

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub totalWorkTime_AfterUpdate()
  3. Dim ttltime As Double
  4.  
  5.   ' you first have to save the record that was just updated 
  6.   DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
  7.  
  8.   ' get the total times  
  9.   Me.calcTime = DSum("TimeValue([DateFiled])", "tblFilingDates", "")
  10.   ttltime = Me.calcTime
  11.  
  12.   ' call the function to calculate days, hours and minutes
  13.   Me.txtTotalTime = totalTime(ttltime)
  14.  
  15. End Sub
  16.  
  17.  
You will also need to put in a form load event as follows:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Form_Load()
  3. Dim ttltime As Double
  4.  
  5.   ' get the total times  
  6.   Me.calcTime = DSum("TimeValue([DateFiled])", "tblFilingDates", "")
  7.   ttltime = Me.calcTime
  8.  
  9.   ' call the function to calculate days, hours and minutes
  10.   Me.txtTotalTime = totalTime(ttltime)
  11.  
  12. End Sub
  13.  
  14.  
I said it was complicated. The problem is that you cannot calculate times over 24 hours which is why you need the function.
Nov 15 '06 #4
NeoPa
32,566 Recognized Expert Moderator MVP
Are you sure about this Mary?
Times, being a fraction of a day should work as any other number behind the scenes to my understanding.
Looks like I'll have to run some tests over my lunch ;).
I'll post my findings, but let me know if you think I've not understood something.
Nov 15 '06 #5
NeoPa
32,566 Recognized Expert Moderator MVP
I tried this with the Now() function originally but, for reproducibility of results I changed it to Date/time literals which are country independant.
Expand|Select|Wrap|Line Numbers
  1. ?Format(#15 Nov 12:37:33#,"d/m/yyyy hh:nn:ss"), Format(#15 Nov 2006 12:37:33#+#11:55:00#,"d/m/yyyy hh:nn:ss")
  2. 15/11/2006 12:37:33         16/11/2006 00:32:33
This indicates that Date/Time fields conform to standard arithmetic rules.
Nov 15 '06 #6
MMcCarthy
14,534 Recognized Expert Moderator MVP
Are you sure about this Mary?
Times, being a fraction of a day should work as any other number behind the scenes to my understanding.
Looks like I'll have to run some tests over my lunch ;).
I'll post my findings, but let me know if you think I've not understood something.
That's not the problem. The problem is that if as I suspect only the time is being recorded then the date field can't be used in the arithmetic.

Therefore as the total time is being summed over all records in the form this would go over 24 hours and that cannot be handled with a specific format or any of the existing date functions.

The result returns a decimal number which needs the function I've included to break it out into days hours and mins.
Nov 15 '06 #7
MMcCarthy
14,534 Recognized Expert Moderator MVP
I need help to make grand total time in continuous forms.
to calculate total work time I use following formula
=format([timeout]+1-[timein]-nz([lunch]);"short time").
but when I make grand total time in form footer (for all records) my result is error.
My grand total must be in format [hh:mm].
thanks,
Barkarlo

Just a note regarding this line in the code

Me.calcTime = DSum("TimeValue ([DateFiled])", "tblFilingDates ", "")

The field and table names here are from the test I ran. Change tblFilingDate to your own table name and [DateFiled] to the field in which you are storing the calculated Total_Hours value. If you are not storing that field you will need to for this to work. Otherwise let me know and I'll change the code accordingly.
Nov 15 '06 #8
NeoPa
32,566 Recognized Expert Moderator MVP
Mary,

You're right. I see what you mean about the days.
But the time element could be better formatted as :
Expand|Select|Wrap|Line Numbers
  1. Format(tTime, "h \hr\s n \mi\n\s")
...though now I test it out - it is a little kludgy - maybe your way's best after all.
Nov 15 '06 #9
MMcCarthy
14,534 Recognized Expert Moderator MVP
Mary,

You're right. I see what you mean about the days.
Don't you know by now I'm always right.



But the time element could be better formatted as :
Expand|Select|Wrap|Line Numbers
  1. Format(tTime, "h \hr\s n \mi\n\s")
...though now I test it out - it is a little kludgy - maybe your way's best after all.
Well DAWHHH!!!



Actually, I knew about the problem as I've come up against it before. Experience is a great teacher.

Mary
Nov 15 '06 #10

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

Similar topics

53
5685
by: Cardman | last post by:
Greetings, I am trying to solve a problem that has been inflicting my self created Order Forms for a long time, where the problem is that as I cannot reproduce this error myself, then it is difficult to know what is going on. One of these Order Forms you can see here... http://www.cardman.co.uk/orderform.php3
4
2290
by: lyndsey | last post by:
i have a database to keep record of jobs in production, and on one of my forms, their is the control . in my form i have hundereds of records (jobs). is there a way i can create something in my record that will show me the grand total price of all the jobs in production. Thanks
6
4680
by: Coleen | last post by:
Hi All :-) Thanks for all of your help Cor :-) I can not get the code you sent me to work in my application. I'm using an aspx datagrid in a web form. I'm getting the following error message when I try this code: "Syntax error in aggregate argument: Expecting a single column argument with possible 'Child' qualifier." Dim dr2 As DataRow = dt_stat_report_3b.NewRow Dim sum As Double =...
4
6363
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 (cost). Users can dynamically add rows to the table so I don't know how many rows might need to be calculated. I need to calculate the total (qty * cost) and put that number in a table cell (or read only input box). I also need to sum the...
0
1495
by: jessicaeatworld | last post by:
Hi, I'm using Access 2003 on Windows XP. I have created a PivotTable View Form and at the bottom is an automatically inserted Grand Total row. I added sum and avg fields and then hid the details so the Grand Total row actually shows totals for each column. It displays perfectly in Access but when I export it, the entire Grand Total row is gone. What can I do to make the PivotTable Form export exactly how it displays in Access? Thank you.
0
2077
by: Racqetsports | last post by:
Hi there, In a gradebook database, student grades must be computed from 2 scores: a Daily grade, and then scores from Assignments. Knowing about nested forms, I am requesting direction on how to set up this particular case of form and subforms. Currently, there are 5 tables: STUDENTS StudentID StudentLName
5
2257
by: Wiley | last post by:
I have created a form that contains 1000s of items, though I have an expression that have calculated the grand total. If I make any changes to my quantities the grand total does not change. Hence how do I use access to continually update and calculate the grand total in a form after each new entry.
4
5650
by: Micheal | last post by:
Greetings Access Group, Being relatively new to Access, I try to work through problems on my own and have been very successful, although I have a conundrum that I have been working on for two days (total 10 hours) and I have yet to resolve it. please excuse me for my lack of terminology, I will try to provide you with the best of information. I currently have a report that contains 2 totals and the percentage of the difference of the 2...
2
3023
by: Bytesmiths | last post by:
I'm using GROUP BY to come up with totals for some items, but would like to either have a grand total at the bottom, or a running total field. I tried to use a variable as I found in several places on the web: SELECT @total := total + value AS `Running Total` but what I'm totalling is an aggregate, and it doesn't seem to work. I tried to explore some options dev.mysql.com, but again, my field seems to be too complex. More specifically,...
0
8555
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...
0
8408
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
7024
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
6064
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
5524
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4032
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...
0
4098
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1686
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1403
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.