|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Entering data automaticaly
How to enter data automaticaly between two dates?
Example:Employee will be in vacation bewteen two dates. how can I enter his vacation hours with one record bewteen those two dates. some like that: <Employee>between <date> and <date> <hours>. Could you help me, please? |
|
#2
|
||||
|
||||
|
Do you need to account for Holidays?
Are you assuming a standard work week (M-F) and a standard 8 hour shift? Is the second date the last Date of Vacation, or the first date back at work? (i.e. Sunday 5/11/2008, or Monday 5/12/2008) |
|
#3
|
|||
|
|||
|
Quote:
If Holiday is in vacation time it's counting like holiday taken. All other is standart work week /M-F/ 8 hours. Fisrt date is start of Vacation, second End of Vacation |
|
#4
|
||||
|
||||
|
OK, well you'll need a table that has the holidays.
The following assumes a table names Holidays that has a field holidayDate this is the date of the Holidays. It is based on a form with input fields for employee name, start date and end date, and a button to do the calculation. However the basic code would be the same if you got the data from a table instead. Code:
Private Sub calcHours_Click()
Dim connDB As ADODB.Connection
Dim miscRs As New ADODB.Recordset
Dim sql As String
Dim currDate As Date
Dim vacHours As Integer
Set connDB = CurrentProject.Connection
Set qry.ActiveConnection = connDB
' assume there's no Holiday and calculate the total vacation hours.
currDate = Me.startDate
vacHours = 0
Do While currDate <= Me.endDate
If DatePart("w", currDate, vbMonday) <= 5 Then
vacHours = vacHours + 8
End If
currDate = DateAdd("d", 1, currDate)
Loop
'Now subtract 8 hours for each holiday that is in the range.
sql = "SELECT HolidayDate " & _
"FROM Holidays " & _
"WHERE HolidayDate >= #" & Me.startDate & "#"
miscRs.Open sql, connDB
Do While miscRs!holidayDate <= Me.endDate
vacHours = vacHours - 8
miscRs.MoveNext
Loop
If vacHours < 0 Then
vacHours = 0
End If
Me.vacationHours = vacHours
End Sub
TA-DA! |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft Access Development > Entering data automaticaly |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|