Select a date range of a seven day week

R

Randy

I need a way to select a previous weekly period of Sun to Monday. The user
needs to select the prior week possibly through a combo box and have a query
return the results for that week...Any ideas...Access 2000...Thanks...Randy
 
K

Ken Snell [MVP]

Perhaps this function that I use will help. You can call it by asking the
user for how many weeks ago the week is.

Dim strWeeks As String
strWeeks = InputBox("How many weeks ago?")
TheSundayDate = DateOfSpecificWeekDay( _
DateAdd("ww", -CInt(strWeeks), Date()), _
1)


'************************************
'* *
'* Function DateOfSpecificWeekDay *
'* *
'************************************

Public Function DateOfSpecificWeekDay(ByVal OriginalDate As Date, _
ByVal intWeekDay As Integer) As Date
' ** THIS FUNCTION RETURNS THE DATE OF THE SPECIFIC DAY OF THE WEEK
' ** IN WHICH THE ORIGINAL DATE IS.
' ** intWeekDay = 1 is Sunday, 2 is Monday, etc.
' Ken Snell 24 May 2005

On Error Resume Next

DateOfSpecificWeekDay = DateAdd("d", -DatePart("w", OriginalDate, _
1) + intWeekDay, OriginalDate)
Err.Clear
End Function
 
Top