HI
I am working on a report based on a query that displays data between 2 different dates.
The query is based on a table that includes one column with Inspection dates, and in the query I added a Criteria 'Between [Start_Date] and [End_Date]'. I also created two parameters in the Query Expr1:[Start_Date] and Expr2:[End_Date].
When report loads it asks me to enter manually the Start and End Date.
I would like to control this by loading a form in the Open_Report Event where dates can be entered with the date picker to make it easier and avoid invalid data. How can I do this?
So far I used this code, but it is still asking me the missing parameters as if there is nothing
Private Sub Report_Open(Cancel As Integer)
Dim rst As DAO.Recordset
Dim dbs As DAO.Database
Dim prm As DAO.Parameter
Dim qdf As DAO.QueryDef
Set dbs = CurrentDb
Set qdf = dbs.QueryDefs("Task Schedule Query by Inspector")
qdf.Parameters.Refresh
qdf.Parameters("Start_DAte").Value = Date
qdf.Parameters("End_Date").Value = Date + 1
Set rs = qdf.OpenRecordset()
End Sub
Thanks in advance
I am working on a report based on a query that displays data between 2 different dates.
The query is based on a table that includes one column with Inspection dates, and in the query I added a Criteria 'Between [Start_Date] and [End_Date]'. I also created two parameters in the Query Expr1:[Start_Date] and Expr2:[End_Date].
When report loads it asks me to enter manually the Start and End Date.
I would like to control this by loading a form in the Open_Report Event where dates can be entered with the date picker to make it easier and avoid invalid data. How can I do this?
So far I used this code, but it is still asking me the missing parameters as if there is nothing
Private Sub Report_Open(Cancel As Integer)
Dim rst As DAO.Recordset
Dim dbs As DAO.Database
Dim prm As DAO.Parameter
Dim qdf As DAO.QueryDef
Set dbs = CurrentDb
Set qdf = dbs.QueryDefs("Task Schedule Query by Inspector")
qdf.Parameters.Refresh
qdf.Parameters("Start_DAte").Value = Date
qdf.Parameters("End_Date").Value = Date + 1
Set rs = qdf.OpenRecordset()
End Sub
Thanks in advance