Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / February 2008

Tip: Looking for answers? Try searching our database.

Is anyone up for a Challenge?  Oh I HOPE SO!!!!

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
TheNovice - 30 Jan 2008 00:07 GMT
To the Best of the Best (yes I am sucking-up early),

Ok here it is:

I am trying to figure out a method that does the following.  I have an
employee who works 5 days a week M-F.  If they call in sick on Monday or
Friday he is assessed a point and a half (1.5), all other days are one (1)
point.

But, if he misses two or more consecutive days it is only 2 points MAX.

The catch is not including Saturday or Sunday

Now if he misses 3 straight weeks, it is still 2 points.

Just to add to the mix, if he comes in in the second week for just one day
and misses the rest of the time they are both 2 points.

We go with a rolling 6 month period (7/29 - 1/29 etc) so the points drop
after the the six month period.

My table(s) has the follow info.

tblPointData
-----------------------------
pdEmpID 'Employee ID
pdClkIn   'Date Clocked-In or Entry Date (if Absent)
pdType   'REG=Regular Day Worked, NOPAY=usually a personal day, NOP S=No Pay
Sick(NOPAY and NOP S are both absences unless a Supervisor Excuses the Missed
Day
pdPoints 'Points assessed

tblEmpSchd
-----------------------------
esEmpID 'Employee ID
esWrkSchdCode 'Work Schedule Code
esWrkU 'Yes/No Days Worked
esWrkM 'Yes/No Days Worked
esWrkT 'Yes/No Days Worked
esWrkW 'Yes/No Days Worked
esWrkR 'Yes/No Days Worked
esWrkF 'Yes/No Days Worked
esWrkS 'Yes/No Days Worked

Can anyone give me a simple method to Code this so that my table
(tblPointdata)will be updated with the points that need to be assessed to
each employee.

Signature

-The Novice
Learn Today, Teach Tomorrow

Great Success is ones ability to ask for Help.

KARL DEWEY - 30 Jan 2008 16:53 GMT
You need a field to record ‘Supervisor Excuses the Missed Day’
tblEmpSchd is only for one week.  How do you track the week before?

Signature

KARL DEWEY
Build a little - Test a little

> To the Best of the Best (yes I am sucking-up early),
>
[quoted text clipped - 43 lines]
> (tblPointdata)will be updated with the points that need to be assessed to
> each employee.
TheNovice - 30 Jan 2008 17:04 GMT
I am not looking per week, this is a Rolling 6 months.

I do have the Info for the Excused Days, and those are filtered out through
a query.

Any Ideas?
Signature

-The Novice
Learn Today, Teach Tomorrow

Great Success is ones ability to ask for Help.

> You need a field to record ‘Supervisor Excuses the Missed Day’
> tblEmpSchd is only for one week.  How do you track the week before?
[quoted text clipped - 46 lines]
> > (tblPointdata)will be updated with the points that need to be assessed to
> > each employee.
KARL DEWEY - 30 Jan 2008 18:31 GMT
>>I am not looking per week, this is a Rolling 6 months.
Does this mean that everyone is on the same shift schedule for six months?

>>I do have the Info for the Excused Days, and those are filtered out through
a query.
That information is necessary to calculate points correctly.  Based on your
table presented points can not be calculated.
Signature

KARL DEWEY
Build a little - Test a little

> I am not looking per week, this is a Rolling 6 months.
>
[quoted text clipped - 53 lines]
> > > (tblPointdata)will be updated with the points that need to be assessed to
> > > each employee.
TheNovice - 30 Jan 2008 20:16 GMT
I have since made chages to to Db.  The data that is extracted from our time
clock systems has the Shift at the time the driver clocks in or out.  so the
information is always there no matter the change in schedules.  Schedule
changes are done to begin the following week (or later) so there is no
conflict in schedules.  

the tblEmpSched only has the esWrkSchdCode and Days and the tblPointdata has
always had WrkSchdCode field.

I just need a sample code that can get me started and I can test and modify
on the fly if necessary.

Signature

-The Novice
Learn Today, Teach Tomorrow

Great Success is ones ability to ask for Help.

> >>I am not looking per week, this is a Rolling 6 months.
> Does this mean that everyone is on the same shift schedule for six months?
[quoted text clipped - 61 lines]
> > > > (tblPointdata)will be updated with the points that need to be assessed to
> > > > each employee.
Jeff Boyce - 31 Jan 2008 13:17 GMT
You may want "the sample code ...", but Karl is pointing out that the data
needed to do the calculation was not available.  Can you write out the
formula for the calculation you want, using the fields you currently have?
If so, post it back here.  The "sample code" you are asking us to write will
have to start with you!

Good luck!

Signature

Regards

Jeff Boyce
www.InformationFutures.net

Microsoft Office/Access MVP
http://mvp.support.microsoft.com/

Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

> I have since made chages to to Db.  The data that is extracted from our time
> clock systems has the Shift at the time the driver clocks in or out.  so the
[quoted text clipped - 73 lines]
> > > > > (tblPointdata)will be updated with the points that need to be assessed to
> > > > > each employee.
Robert Morley - 31 Jan 2008 17:44 GMT
But if he's already filtering out days that the manager has excused, as he
said he is, then there's no problem.  That would naturally create a gap in
the consecutive dates, causing the point count to reset as though that day
had been worked normally.

Or have I missed something?

Rob

> You may want "the sample code ...", but Karl is pointing out that the data
> needed to do the calculation was not available.  Can you write out the
[quoted text clipped - 3 lines]
>
> Good luck!
Robert Morley - 31 Jan 2008 18:31 GMT
I'm not sure quite how tblEmpSchd fits into this, so I'm ignoring it for
now.  If it's for people who work other than M-F, then you'll have to
massively re-write teh IsConsecutive function, and possibly the SickPoints
function.  For now, I'm assuming that all employees work M-F.  I've also
assumed that tblPointData already has entries in it for each EmployeeID and
Date for the last six months, and only needs to be updated with sick points.

Given that, I would structure the code something like this (this is VERY
light on details and probably won't do everything you need, but should give
you a rough outline to start from...it's also untested, so there may be bugs):

Public Function IsConsecutive(ByVal FirstDay As Date, ByVal NextDay As Date)
As Boolean
    'Depending on the structure of your query, etc., you may need to
    'expand this significantly to discount holidays, etc.
    IsConsecutive = ((NextDay - FirstDay) = 1) Or _
        (((NextDay - FirstDay) = 3) And _
        (Weekday(FirstDay, vbSunday) = vbFriday) And _
        (Weekday(NextDay, vbSunday) = vbMonday))
End Function

Public Function SickPoints(ByVal ThisDay As Date, ByVal PointsSoFar As
Double) As Double
    'Returns 1 or 1.5, depending on weekday
    'Or returns the difference if more than 2 points accumulated.
    'Thus stopping at 2 points.
    Dim dblSickPoints as Double
    Select Case Weekday(ThisDay, vbSunday)
        Case vbMonday, vbFriday
            dblSickPoints = 1.5
        Case Else
            dblSickPoints = 1
    End Select

    If PointsSoFar + dblSickPoints > 2 Then dblSickPoints = 2 - PointsSoFar
End Function

'Fragment of main code:  assumes table is open as recordset called rs,
'ordered by pdEmpID, pdClkIn.

Dim strEmpID As String
Dim dtClkIn As Date

With rs
    strEmpID = vbNullString
    dtClkIn = 0
    Do Until .EOF
        If strEmpID <> !pdEmpID.Value Then
            dblPtsSoFar = 0
            strEmpID = !pdEmpID.Value
            dtClkIn = !pdClkIn.Value
        End If
        If !pdType = "NOP S" Then
            If Not IsConsecutive(dtClkIn, !pdClkIn.Value) Then _
                dblPtsSoFar = 0
            !pdPoints.Value = SickPoints(!pdClkIn.Value, dblPtsSoFar)
            dblPtsSoFar = dblPtsSoFar + !pdPoints.Value
            .Update
        Else
            dblPtsSoFar = 0
        End
        .MoveNext
    Loop
End With

As I said, the above will definitely need some testing and debugging, as I'm
writing this completely off the top of my head, and there were things I
didn't necessarily understand.  But give it a whirl and see where it gets you.

Rob

> To the Best of the Best (yes I am sucking-up early),
>
[quoted text clipped - 43 lines]
> (tblPointdata)will be updated with the points that need to be assessed to
> each employee.
TheNovice - 01 Feb 2008 00:02 GMT
Robert,

There is an old adage that says “Give a man a Fish, he eats for a Day, teach
him how to fish and he eats for a lifetime.

This is my starting point, and I greatly appreciate the push.

Charles Davis
Signature

-The Novice
Learn Today, Teach Tomorrow

Great Success is ones ability to ask for Help.

> I'm not sure quite how tblEmpSchd fits into this, so I'm ignoring it for
> now.  If it's for people who work other than M-F, then you'll have to
[quoted text clipped - 114 lines]
> > (tblPointdata)will be updated with the points that need to be assessed to
> > each employee.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.