Thanks. I will use your suggestion but in searching for another option I
tried the following and I'm curious why I'm getting an error.
Private Sub Command12_Click()
'Opens Last Month Summary report sorted alphabetically
Dim strWhereCategory As String
Dim dtStartDate As Date
Dim dtDay As Integer
Dim dtmonth As Integer
Dim dtyear As Integer
If Month(Date) - 1 = 0 Then
dtStartDate = DateSerial((Year(Date) - 1), 12, 1)
Else
dtStartDate = DateSerial((Year(Date)), (Month(Date) - 1), 1)
End If
dtmonth = Month(dtStartDate)
dtyear = Year(dtStartDate)
dtDay = Day(dtStartDate)
strWhereCategory = "[ship date] >= dateserial(dtyear,dtmonth,dtday) and
[ship date] <dateserial (year(),month(),1)
"
title = "Last Month Deliveries"
DoCmd.OpenReport "rptSCSMonthEndSummary", acViewPreview, ,
strWhereCategory
End Sub
--
TIA
Rick Brandt said:
No you won't, but that is not the complete expression.
DateSerial(Year(Date()), Month(Date())-1, 1)
DateSerial is fully "year wrap aware" so the zeroth month of one year will
return the 12th month of the previous year.