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
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