Microsoft Access Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft Access Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
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  
Old May 12th, 2008, 04:30 PM
Lynx Lynx is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 2 Lynx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 m 57 sec
Reputation Power: 0
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?

Reply With Quote
  #2  
Old May 12th, 2008, 04:43 PM
dykebert's Avatar
dykebert dykebert is offline
Contributing User
Click here for more information. Click here for more information
 
Join Date: Apr 2008
Posts: 195 dykebert User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 Days 1 h 37 m 18 sec
Reputation Power: 1
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)

Reply With Quote
  #3  
Old May 12th, 2008, 07:42 PM
Lynx Lynx is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 2 Lynx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 m 57 sec
Reputation Power: 0
Quote:
Originally Posted by dykebert
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)


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

Reply With Quote
  #4  
Old May 12th, 2008, 11:26 PM
dykebert's Avatar
dykebert dykebert is offline
Contributing User
Click here for more information. Click here for more information
 
Join Date: Apr 2008
Posts: 195 dykebert User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 Days 1 h 37 m 18 sec
Reputation Power: 1
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!

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft Access Development > Entering data automaticaly


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway