Day problem (1 Viewer)

ansentry

Access amateur
Local time
Today, 15:50
Joined
Jun 1, 2003
Messages
995
What I am trying to achieve is when this form is opened on a Monday then it will show previous "Sunday & Saturday & Friday" details.

If it is open on any other day then just the previous day.(this part is working fine)

The code below works fine for strSaturday but I want to combine
strFriday and strSaturday and strSunday and don't know how.


Below is my code, Thank you in advance.

Private Sub cmdPreviousDays_Click()

Dim stDocName As String
Dim stLinkCriteria As String
Dim strPrevDate As String
Dim strMondayDate As String
Dim strFriday As String
Dim strSaturday As String
Dim strSunday As String



strPrevDate = Date - 1

strFriday = Date - 3

strSaturday = Date - 2

strSunday = Date - 1

strMondayDate = strSaturday


If WeekDay(Date) = 2 Then


stLinkCriteria = "[MyDate] = #" & strMondayDate & "#"

Else

WeekDay (Date) > 2 Or 1


stLinkCriteria = "[MyDate] = #" & strPrevDate & "#"
End If


stDocName = "Frm_PrevDayDeliveries"

DoCmd.Openform stDocName, , , stLinkCriteria

DoCmd.Close acForm, "Frm_ManagementMenu"



End Sub
 

Calvin

Registered User.
Local time
Yesterday, 22:50
Joined
Jun 4, 2003
Messages
286
Try replacing the following line in the if statment:
Code:
stLinkCriteria = "[MyDate] = #" & strMondayDate & "#"
with the following:
Code:
stLinkCriteria = "[MyDate] Between #" & strFriday & "# AND #" & strPrevDate & "#"
 

ansentry

Access amateur
Local time
Today, 15:50
Joined
Jun 1, 2003
Messages
995
day problem

Calvin,

Thank you very much, works like a charm.

Easy when you know how.


Regards

:) :) :)
 

Users who are viewing this thread

Top Bottom