I am using windows 2000pro with access 2000.
I am trying to make a database for our HR department, that would allow our HR Director to type in an employee's ID number into a form and then select the dates the employee took off from work.
(I have the calander add-in 8.0 setup to easily select the dates already) There are two Date Fields, "Leave Date", and "Return Date" where the calander selections are stored. They are in the 12/25/2006 Format.
There then is a combo box field for the "Type of Absence" the employee took. Options such as "Paid Time Off", "Unpaid Absence", "Paid Vacation",and "Volunteer Hours" are the choices in the combo box.
The HR Director asked if I could have the "Return Date" field value, subtracted from the "Leave Date" field value. Thus giving me the total number of days taken off.
So, Step 1 would be to have the dates subtracted from on another
Step 2. Is to have the total number of days taken off, broke down into hours.
Step3. Depends on wether or not "Paid Vacation" is selected for the "Type of Absence field". Because Paid Vacation is saved up, I plan to make another table for those hours to be manually stored in.
Step 4 will Idealy subtract the hours the employee has taken off from the stored vacation hours. That is all assuming that Paid Vacation is selected.
If "Unpaid Absence" or "Volunteer hours" is selected, they just need totaled up in a table.
Hopein you got all that, my main question, is;
What steps will it take codewise to make my Form subtract the two calendar dates from one another? i.e. "Leave Date" = 12/20/2006 and "Return Date" = 12/23/2006. Subtracting them, should give me 3 days off. Not sure how to start that one.
From there, I have the program down in theory...3 days * 8 hrs a day, so 24 hours which is then subtracted from the X amount of hours stored in the employee's Paid Vacation field.
I am just learning VBA and I am still just a bit uneasy with things. Input is greatly appreciated.
8 12804
I am using windows 2000pro with access 2000.
I am trying to make a database for our HR department, that would allow our HR Director to type in an employee's ID number into a form and then select the dates the employee took off from work.
(I have the calander add-in 8.0 setup to easily select the dates already) There are two Date Fields, "Leave Date", and "Return Date" where the calander selections are stored. They are in the 12/25/2006 Format.
There then is a combo box field for the "Type of Absence" the employee took. Options such as "Paid Time Off", "Unpaid Absence", "Paid Vacation",and "Volunteer Hours" are the choices in the combo box.
The HR Director asked if I could have the "Return Date" field value, subtracted from the "Leave Date" field value. Thus giving me the total number of days taken off.
So, Step 1 would be to have the dates subtracted from on another
Step 2. Is to have the total number of days taken off, broke down into hours.
Step3. Depends on wether or not "Paid Vacation" is selected for the "Type of Absence field". Because Paid Vacation is saved up, I plan to make another table for those hours to be manually stored in.
Step 4 will Idealy subtract the hours the employee has taken off from the stored vacation hours. That is all assuming that Paid Vacation is selected.
If "Unpaid Absence" or "Volunteer hours" is selected, they just need totaled up in a table.
Hopein you got all that, my main question, is;
What steps will it take codewise to make my Form subtract the two calendar dates from one another? i.e. "Leave Date" = 12/20/2006 and "Return Date" = 12/23/2006. Subtracting them, should give me 3 days off. Not sure how to start that one.
From there, I have the program down in theory...3 days * 8 hrs a day, so 24 hours which is then subtracted from the X amount of hours stored in the employee's Paid Vacation field.
I am just learning VBA and I am still just a bit uneasy with things. Input is greatly appreciated.
- DateDiff ('d', Format([Leave Date], '\#dd/mm/yyyy\#'), Format([Return Date], '\#dd/mm/yyyy\#'))
This should give you the three days required.
Mary
NeoPa 32,556
Expert Mod 16PB - DateDiff ('d', Format([Leave Date], '\#dd/mm/yyyy\#'), Format([Return Date], '\#dd/mm/yyyy\#'))
This should give you the three days required.
Mary
Nice to see the delimiters in there nicely Mary. If I'm being picky (Moi? - Jamais!) the date format should be m/d rather than d/m in SQL. Otherwise it's perfect.
In fact, in this case, literals are probably not required though. That means you should get away with simply : - DateDiff ('d', [Leave Date], [Return Date])
This code can be used even within your SQL.
One thing I would point out is that this makes no allowance for weekends or holidays. That is a whole new can of worms and frequently requires special VBA code to handle.
Thanks for the help, though I am still missing something. I have my "LeaveDate" and "ReturnDate" fields, and the calendar coded as so; - Option Compare Database
-
Option Explicit
-
Dim nlbOriginator As ComboBox
-
-
Private Sub LeaveDate_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
-
Set nlbOriginator = LeaveDate
-
Calendar.Visible = True
-
Calendar.SetFocus
-
If Not IsNull(nlbOriginator) Then
-
Calendar.Value = nlbOriginator.Value
-
Else
-
Calendar.Value = Date
-
End If
-
-
End Sub
-
-
Private Sub ReturnDate_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
-
Set nlbOriginator = ReturnDate
-
Calendar.Visible = True
-
Calendar.SetFocus
-
If Not IsNull(nlbOriginator) Then
-
Calendar.Value = nlbOriginator.Value
-
Else
-
Calendar.Value = Date
-
End If
-
End Sub
-
-
Private Sub Calendar_Click()
-
nlbOriginator.Value = Calendar.Value
-
nlbOriginator.SetFocus
-
Calendar.Visible = False
-
Set nlbOriginator = Nothing
-
End Sub
The text box, I have set to recieve the calculated number of days gone, is called "DaysGone". I assume I need to set another global value, to hold the value of the two dates being subtracted? Then I make another sub procedure, for the calendar or for the "DaysGone" field? (It would be there that I insert your listed code?)
I could be way off, any thoughts?
Thanks,
Remington
Thanks for the help, though I am still missing something. I have my "LeaveDate" and "ReturnDate" fields, and the calendar coded as so; - Option Compare Database
-
Option Explicit
-
Dim nlbOriginator As ComboBox
-
-
Private Sub LeaveDate_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
-
Set nlbOriginator = LeaveDate
-
Calendar.Visible = True
-
Calendar.SetFocus
-
If Not IsNull(nlbOriginator) Then
-
Calendar.Value = nlbOriginator.Value
-
Else
-
Calendar.Value = Date
-
End If
-
-
End Sub
-
-
Private Sub ReturnDate_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
-
Set nlbOriginator = ReturnDate
-
Calendar.Visible = True
-
Calendar.SetFocus
-
If Not IsNull(nlbOriginator) Then
-
Calendar.Value = nlbOriginator.Value
-
Else
-
Calendar.Value = Date
-
End If
-
End Sub
-
-
Private Sub Calendar_Click()
-
nlbOriginator.Value = Calendar.Value
-
nlbOriginator.SetFocus
-
Calendar.Visible = False
-
Set nlbOriginator = Nothing
-
End Sub
The text box, I have set to recieve the calculated number of days gone, is called "DaysGone". I assume I need to set another global value, to hold the value of the two dates being subtracted? Then I make another sub procedure, for the calendar or for the "DaysGone" field? (It would be there that I insert your listed code?)
I could be way off, any thoughts?
Thanks,
Remington
If you have the field "DaysGone" on your form. Then you just have to decide when you want to trigger this event. You could put the code behind a command button and just code as follows. -
Private Sub CommandXX_Click()
-
Me.DaysGone = DateDiff ('d', [Leave Date], [Return Date])
-
End Sub
-
Mary
- Me.DaysGone = DateDiff ('d', [Leave Date], [Return Date])
I am not having any luck getting this to work. I keep getting an error, wich takes me to the (' just before the d',[Leave Date]
Other questions: What is the Me. ??
Sorry to be a pain ;)
Me.DaysGone = DateDiff ('d', [Leave Date], [Return Date])
I am not having any luck getting this to work. I keep getting an error, wich takes me to the (' just before the d',[Leave Date]
Other questions: What is the Me. ??
Sorry to be a pain ;)
Not a problem.
Me. is just a way of referring to the current form.
Sorry this was my error. Try this instead ... -
Me.DaysGone = DateDiff ("d", [Leave Date], [Return Date])
Mary
Awesome! Thanks Mary, your an angel.
It works great now, much thanks.
Awesome! Thanks Mary, your an angel.
It works great now, much thanks.
You're welcome!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Ken |
last post by:
$expirationdate = 4/15/2005
$startdate = 3/1/2005
I would like to determine the number of days between the above dates.
My approach:
$startdate = strtotime($startdate); // change to a string...
|
by: sylvian stone |
last post by:
Hi,
I've used standard date functions in the past, but need to create
something a little different, as I am working on an investment
calculator.
What I need to do is validate two dates, and...
|
by: John Hanley |
last post by:
I created a function that breaks down a date into broken down time, I
subtract a certain number of seconds from that, then use mktime() to
recompute the calendar time.
It works basically except...
|
by: Russell |
last post by:
I have an assignment that I have to complete. I have to write a
windows app in C#. Here is the spec:
1/ Date Comparison
Build a program that will find the number of days between two dates.
You...
|
by: Atley |
last post by:
I am trying to get a overall difference on two dates,
I can get the difference in Years, Months, Weeks, Days, Hours, Minutes,
Seconds, no problems...
What I cannot seem to figure out is how to...
|
by: Larry Bird |
last post by:
I want to use TimeSpan to determine the differences between two date to
include time. My input data is in the following format:
12/25/2004 12:23:00 AM or 01/05/2005 11:59:00 PM
How do I get...
|
by: Brandon |
last post by:
I'm using PHP with MySQL 4.x and was having trouble converting a
datetime from MySQL into a formatted string until I ran across this
solution that converts a YYYY-MM-DD HH:MM:SS string into a...
|
by: dan |
last post by:
Am i breaking any rules when I loop dates like
// Determine Memorial Day
intFlag = 0;
memDayHol = new Date (currentYear, 4, 31);
while (intFlag == 0) {
if (memDayHol.getDay() == 1) {intFlag...
|
by: learning |
last post by:
Hi how can I instaltiate a class and call its method. the class has
non default constructor. all examples i see only with class of defatul
constructor. I am trying to pull the unit test out from...
|
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,...
|
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$) {
}
...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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,...
|
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,...
| |