-----Original Message-----
My solution to this is a bit complicated, but it's worked
for me before:
On your first form, create two global variables:
WeekStart and WeekEnd.
Dim intWeekday As Integer
intWeekday = Weekday(Date)
Select Case intWeekday
Case 1 'Sunday
WEEK_START = Date
WEEK_END = DateAdd("d", 7 - intWeekday, Date)
Case 7 'Saturday
WEEK_START = DateAdd("d", -7 + intWeekday, Date)
WEEK_END = Date
Case Else
WEEK_START = DateAdd("d", 1 - intWeekday, Date)
WEEK_END = DateAdd("d", 7 - intWeekday, Date)
End Select
<<
On your command button's Click event, put this code:
Dim strSQL As String
'Open the second form
DoCmd.OpenForm "frmSomeFormName"
'Create the query behind the second form
strSQL = "SELECT tblTest.RentNo, tblTest.DateOut,
tblTest.Cust, tblTest.DueDate" & _
" FROM tblTest" & _
" WHERE (((tblTest.DueDate) Between #" &
WEEK_START & "# And #" & WEEK_END& "#));"
'Open the second form and filter it based on the above SQL
Forms!frmSomeFormName.RecordSource = strSQL
Forms!frmSomeFormName.Requery
This should work.
Hope this helps,
Crystal
.