Hi,
I have an issue which I can't resolve so would like some advice.
I'd like to generate a report between two dates in the [Date Worked] field passed as criteria to the report. Those dates are from 30th June (what ever year we're in) to today's date. I'd then like to export it to Excel automatically but one step at a time.
When I click the button a parameter field box opens and asks me 'stDateField' and throws a 3071 error (expression typed incorrectly or too complex).
Can anyone help me out please?
I have an issue which I can't resolve so would like some advice.
I'd like to generate a report between two dates in the [Date Worked] field passed as criteria to the report. Those dates are from 30th June (what ever year we're in) to today's date. I'd then like to export it to Excel automatically but one step at a time.
When I click the button a parameter field box opens and asks me 'stDateField' and throws a 3071 error (expression typed incorrectly or too complex).
Can anyone help me out please?
Code:
Private Sub cmdExportReport_Click()
Dim stDocName As String
Dim stStartDate As String
Dim stEndDate As String
Dim todaysYear As Integer
Dim stReportCriteria As String
Dim stDateField As String
stDocName = "rptProjectTimesbyDate"
stEndDate = Date + 1
stDateField = "[Date Worked]"
todaysYear = Year(Date)
stStartDate = DateSerial(todaysYear, 30, 6)
stStartDate = Format(stStartDate, "mm/dd/yyyy")
stReportCriteria = "[stDateField] Between #" & stStartDate & "# And #" & stEndDate & "#"
Debug.Print stReportCriteria
DoCmd.OpenReport stDocName, acPreview, , stReportCriteria
End Sub
Last edited: