Stuart McLachlan
stuart at lexacorp.com.pg
Wed May 11 17:10:34 CDT 2005
On 11 May 2005 at 9:08, Joe Rojas wrote:
> I have a report that only has a bar graph chart on it.
> What I am trying to do is have the user prompted for a date range that will
> be used to qualify what records are returned.
> I thought that if I change the two dates in the qReportData (see below) to
> something like [Enter Start Date] and [Enter End Date] that this would give
> me what I was looking for but instead I get an error message that reads:
> "The Microsoft Jet database engine does not recognize '[Enter Start Date]'
> as a valid field name or expression"
>
You can't use paramaters in this situation. A common solution is to use
static functions. Here's how to do it using funcitons StartDate() and
ENdDate():
Have a "Report Selection Form" whith two text boxes (txtStartDate and
txtEndDate) and buttons to print/preview your reports.
In each button's on_click use
StartDate() txtStartDate
EndDate() txtEndDate
DoCmd.OPenReport.......
In your query, use
WHERE [DateOpened] BETWEEN StartDate() AND EndDate()#5/1/2005# AND
#5/7/2005#
Place these two functions in a module:
Static Function StartDate(Optional strInput As String) As Date
Dim dteStore As Date
If strInput > " " Then dteStore = DateValue(strInput)
StartDate = dteStore
End Function
Static Function EndDate(Optional strInput As String) As Date
Dim dteStore As Date
If strInput > " " Then dteStore = DateValue(strInput)
EndDate = dteStore
End Function
--
Stuart