Code for last weeks data

torquay

Registered User.
Local time
Today, 09:01
Joined
Dec 27, 2005
Messages
85
Hi I am trying to get the info for sales from last week (ending on Saturday and new week starting Sunday) and this week starting on Sunday case 4 and 5.
For some reason I can easily go back 7 days from today but not last week that ends Saturday
I am really struggling with this
Heres what I have I have tried all over to get an answer but to no avail

Private Sub grpChoice_AfterUpdate()
Dim dDate As Date
Select Case grpChoice.Value
Case 1: dDate = "15/02/2011"
Case 2: dDate = "1/1/" & Year(Date)
Case 3: dDate = Month(Date) & "/1/" & Year(Date)
Case 4:
Case 5:
End Select
Me.LastWeekSalesSub.Form.Filter = "[OrderDate]>=#" & dDate & "#"
Me.LastWeekSalesSub.Form.FilterOn = True
If dDate = "15/02/2011" Then
Me.LastWeekSalesSub.Form.FilterOn = False
End If
End Sub

Thanks for your guidance
 
From my date functions reference:

Code:
    '-------------------------------------
    'First of previous week (Monday)
    '-------------------------------------
    myDate = (dte - Weekday(dte, vbMonday) + 1) - 7

    '-------------------------------------
    'Last of previous week (Monday)
    '-------------------------------------
    myDate = dte - Weekday(dte, vbMonday)

You can make the relevant adjustments.
 

Users who are viewing this thread

Back
Top Bottom