Full Version: Using DateDiff
UtterAccess Forums > Microsoft® Access > Access Date + Time
I am new to access and have a dilemma. I have an Employee database which has three tables. I have the employee table for employee details, a holiday table and a sickness table. I've set up the relationships etc and a form which displays info about an employee. I can insert (through the form) a start and end date of a holiday or a sickness/absence and I want to calculate the number of working days the employee has had off each time. For example, an employee has 20 days holiday entitlement, and if an Employee books a holiday I enter the start date and end date into the form and I then want the form to deduct the total number of working days from the holiday entitlement. How do I implement this within the form? If I have a DateDiff function in a module, how do I get the form to use this function?
Welcome to Utter Access!

Oneed to point out that it sounds like you have not properly normalized you table structure. You should not have separate tables for holiday and sickness/absence. This should be a single table. Since you want to calculate the total time off, it will be a lot easier if all the data is in a single table.

About your code:

What module do you have the DateDiff in?
Where is it located?
Is it a Function where you pass to two dates and it returns the days?

I would recommend that you use a text box on your form that calculates the days in the control source. Maybe call your function in the code module you created.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.