Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print date entered in Parameter query in the Header of a Report 2

Status
Not open for further replies.

DataNick

Technical User
Jan 1, 2003
16
US
Hi All!
I've got reports that use Parameter queries as their data source. Is it possible to print in the header of my report, the last date entered as a month/yyyy? I usually use 2 inputs for the date range. So if I enter for example (2/1/04) for the first date, and then (2/28/04) for the second date, is it possible to display that second date entered as February, 2004 in the header of my report?
Thanks for your time,
Nick
 
there are two ways to do this
first since it has parameters I assume you have in the queries criteria [enter_start_date] or something to that effect and the same for end date

in a textbox place ="data between " & [enter_start_date] & " and " & [enter_end_date]

or you can also use dmax()and dmin() functions with the datefield as the field and the reports query as the source
 
The way I would handle this is to use a form interface for the query, perhaps with the calendar control. The user would enter the parameter dates into txtBeginDate and txtEndDate. Then in your report I would create 2 label controls, one for the date range(lblDateRange) and the other for the month(lblMonth).

Private Sub Report_Open(Cancel As Integer)


'Open the report in maximized view
DoCmd.Maximize

'Set the date label to equal the report parameters
Me.Controls("lblDateRange").Caption = "For period between " & Forms("frmCalendarReports")("txtBeginDate") _
& " and " & Forms("frmCalendarReports")("txtEndDate")
'Set the month label caption
Me.controls("lblMonth") = Format((Forms("frmCalendarReports")("txtBeginDate"),"mmmm")&", "&Year(Forms("frmCalendarReports")("txtBeginDate")

End Sub
 
Thanks guys, both of you have given me excellent solutions. I appreciate the community help/spirit, and hope I can be of help to others in the future.
Thanks again,
Nick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top