find records with due date next monday and next week

Misiek

Registered User.
Local time
Today, 21:57
Joined
Sep 10, 2014
Messages
248
Hello,

I have been searching for past 6 hours but can't find my answer.
Have an after update event, where depending on selection a report will open and show all records with due date for next Monday, or with due date within next week.

here's my vba:
Code:
Private Sub cboAPduedate_AfterUpdate()
If cboAPduedate = "Today" Then
DoCmd.OpenReport "R_APdailyplan", acViewPreview, , "tTaskDueDate=date()"
ElseIf cboAPduedate = "Tomorrow" Then
DoCmd.OpenReport "R_APdailyplan", acViewPreview, , "tTaskDueDate=date()+1"
ElseIf cboAPduedate = "Saturday" Then
DoCmd.OpenReport "R_APdailyplan", acViewPreview, , "tTaskDueDate=Date() + 7 - Weekday(Date())"
ElseIf cboAPduedate = "Sunday" Then
DoCmd.OpenReport "R_APdailyplan", acViewPreview, , "tTaskDueDate=date() + 7 - Weekday(Date())+1"
ElseIf cboAPduedate = "Monday" Then
DoCmd.OpenReport "R_APdailyplan", acViewPreview, , "tTaskDueDate= DatePart("ww",Date())+1 "
ElseIf cboAPduedate = "Next Week" Then
DoCmd.OpenReport "R_APdailyplan", acViewPreview, , "tTaskDueDate= ???"
End If
End Sub

Can anyone help me please?
 
The next week interval depends on Date() and what you consider the
next" week. Is it M-S, S-F, or whatever. It can be computed, but not with the info you provided. You can compute it in a function..
 
Yes Monday-Sunday.
How to do it please, too advanced for me :/
 
If Date() is a Monday, is the next week the next Mon-Sun?
 
The Monday of next week after "AnyDate" is

PHP:
AnyDate + 8 - Weekday(Me.dt, vbMonday) Mod 8

Add 6 and you get the Sunday of that week.
 
you already have the correct formula for next Sunday, just follow it and that well be your next Monday.

tTaskDueDate=date() + 7 - Weekday(Date())+2

Next week would be:

tTaskDueDate=date() + 7
 
llkhoutx,

php? that wouldnt work...?


arnelgp,
both give "syntax error, missing operator in query expression"
 
What do you mean by "php?"? I gave you Access VBA code.
 
llkhoutx,
No this dont work,


arnelgp,
I made a typing error, so first one works but second one didnt, so I modified it.

This works for me.
Code:
.....
ElseIf cboAPduedate = "Monday" Then
DoCmd.OpenReport "R_APdailyplan", acViewPreview, , "tTaskDueDate=date() + 7 - Weekday(Date())+2 "
ElseIf cboAPduedate = "Next Week" Then
DoCmd.OpenReport "R_APdailyplan", acViewPreview, , "tTaskDueDate >= date() + 7 - Weekday(Date())+2 and tTaskDueDate <= date() + 7 - Weekday(Date())+7"


Thanks all for help :)
 

Users who are viewing this thread

Back
Top Bottom