Results 1 to 3 of 3
  1. #1
    jonesy29847 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Detroit area
    Posts
    43

    Incorrect sorting in report.

    I am using Access, to manage service reports, invoices, and expense reports for my contracting business. Since we work overtime, I have written a VB program to calculate, straight time, overtime, and double time hours.



    The VB program, tracks ST, OT and DT, based on hours worked, DT is calculated based on Sunday work, and requires Monday through Sunday processing. I think that multiple weekdays are presented to the routine, thus the error.

    HTML Code:
    Function CalcOT(TaskDate As Date, hoursThisDay As Double) As Single
    If Iter = 0 Then
        Exit Function
    End If
    Iter = Iter - 1
    dayOfWeek = DatePart("w", TaskDate)
    Open "c:\OTCalc.txt" For Append As #1
    
    If dayOfWeek = vbSunday Then
        DTSum = DTSum + hoursThisDay
        DTAcc = DTAcc + DTSum
        Call DebugPrint(TaskDate, hoursThisDay, "vbSunday")
        CalcOT = STAcc
        Exit Function
    End If
    
    If dayOfWeek = vbMonday Then
        STAcc = STAcc + hoursThisDay
        STSum = 0
        OTSum = 0
        OTFlag = False
        Call DebugPrint(TaskDate, hoursThisDay, "vbMonday")
        CalcOT = STAcc
    End If
    
    If OTFlag = False And dayOfWeek <> vbMonday Then
        STSum = STSum + hoursThisDay
        STAcc = STAcc + hoursThisDay
        If STSum > 50 Then
            OTSum = STSum - 50
            STSum = STSum - OTSum
            STAcc = STAcc - OTSum
            OTAcc = OTAcc + OTSum
            'STAcc = STAcc + hoursThisDay
            OTFlag = True
        End If
        Call DebugPrint(TaskDate, hoursThisDay, "<> vbMonday, OTFlag false on entry")
        CalcOT = STAcc
        Exit Function
    End If
    
    If OTFlag = True Then
        OTSum = OTSum + hoursThisDay
        OTAcc = OTAcc + hoursThisDay
        Call DebugPrint(TaskDate, hoursThisDay, "default")
        CalcOT = STAcc
        Exit Function
    End If
    
    End Function
    I ran invoices, for a two week period, and the hour calculations were incorrect. The report, does not seem to sort correctly, and I suspect this is the root cause of the hour calculation error. The query, used to create the report, specifies the sorting is to be by the date the task was performed.

    I have not defined a key field in my table, and suspect that somehow this is reason the sort does not work correctly in the report, running the query results in correctly sorted records.

    Any suggestions?

    Thanks in advance for you help.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Sorting for a report has to be specified in Sorting and Grouping. In 2007 it's on the Design tab, Grouping and Totals section.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    jonesy29847 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Detroit area
    Posts
    43
    Perfect, Thanks.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Sorting a Report by a Calculated field
    By mulefeathers in forum Reports
    Replies: 1
    Last Post: 05-22-2010, 08:21 PM
  2. report formating/sorting problem
    By bill4364 in forum Reports
    Replies: 1
    Last Post: 02-19-2010, 08:15 PM
  3. Incorrect summation in report footer
    By wizard_chef in forum Reports
    Replies: 2
    Last Post: 12-07-2009, 06:53 AM
  4. sorting a field in report
    By Philangr8 in forum Reports
    Replies: 3
    Last Post: 08-26-2009, 05:38 PM
  5. Sorting data in a report
    By rjsiler in forum Reports
    Replies: 1
    Last Post: 08-04-2008, 01:40 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums