473,387 Members | 1,904 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.

How to sum records between two dates on a form?

I am responsible for tracking training hours each year for a number of employees.

I have just developed a database that includes both the fields "date" (of training) and "hours" I want to sum the hours of training for each year. Say <01/01/2010 for this year and for years going forward either >=01/01/2011 and <=12/31/2011 or just >12/31/2010
Nov 5 '10 #1
1 3225
gnawoncents
214 100+
First, if your field is really named date, I recommend changing it to something else as "date" is a reserved word. Something like TrainingDate would work fine. That said, try this:

I set up a table (YourTableName) and added two columns (hours and TrainingDate). I then created a form with two unbound controls: txtDateYear and txtTotalHours. In the after update field of txtDateYear I have the following code:

Expand|Select|Wrap|Line Numbers
  1. Private Sub txtDateYear_AfterUpdate()
  2.  
  3. txtTotalHours = DSum("[hours]", "YourTableName", "[TrainingDate] Like '*" & [txtDateYear] & "'")
  4.  
  5. End Sub 
When you type/select a year from txtDateYear it will automatically populate txtTotalHours with the total number of hours for that year.

Let me know if you have any questions.
Nov 6 '10 #2

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

Similar topics

9
by: Rimuen | last post by:
Have two text form with dates i need to compare before submitting, the second should always be a date later the first one. Anyone have a script for this ?? Thanks.......
0
by: Wolfgang Kreuzer | last post by:
Hi, I am starting to migrate an Access 2.0 application to Access 2000 (I know it's not the latest version, but ist supported in our company). I found some funny behaviours where I could not...
4
by: glenhong | last post by:
Hi I need some help here. I am running Access 2003. I have an Access DB linked (Front-end) to another Access DB (Back-end). I have a Form which has a third party grid on it. The grid is...
1
by: Dixie | last post by:
I have a continuous form with a variable number of records showing on it. Each record has about 8 fields. I want to be able to copy all of these records, then paste them to the underlying table...
2
by: john saul | last post by:
Hi, I searched through some of the help topics and found one that worked for my problem. But now have a new problem. I have two forms linked together and wanted to populate the feild of the...
1
by: jodstar | last post by:
Hi I am still very new at this but need help with a database problem. To make things simple, I have a database with a form (frmDataEntry) where users can input information (that mostly goes into...
1
by: Lumpy | last post by:
Hi all, I have have been lucky to get some good advice in regards to some access questions I have had so far. The good news is I am almost done with this project but I seem to have hit another...
3
by: Grubsy4u | last post by:
Hi my name is Daniel, I am in the middle of building a database. The problem is i have turned some queries into forms, and i was wondering if it was possible to insert the total of records into...
0
by: don.fleming | last post by:
Greetings, Forms programming not my specialty, appreciated any advice on my direction I'm going with this. Basic need my client has is to "clone" the existing 3 tables records being viewed on a...
7
by: ndhvu | last post by:
Tables: Buy_Header and Buy_Detail. - Buy_Header: info. of each buy (buy_id(PK, auto number), date, shop, bought_by, ...) - Buy_Detail: info. of each item from each buy (buy_detail_id(PK, auto...
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: 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: 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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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.