View Full Version : Generate a date in report from calender control


JPW
03-16-2008, 02:39 PM
I have a report that is connected to a filter that is connected to two calender controls.

The user loads up the relevant form and choses a date from the 'Date From' calender control and then selects another date in the 'Date To' calender control and then presses a macro button which then generates a query/report that works perfectly well so far. All information I want and that I expect is there.

However, the user will most likely be selecting dates within a calender month so never will he/she do a for example 'Date From' - 17/03/08 to 'Date To 19/05/08.

I would like on the report for the report to show the relevant month of that report and year too. So if my user selects 'Date From' 01/02/08 to 'Date to' 21/02/08 then I'd like 'February 2008' to be displayed on my form in the header.

Is there a way to do such a function?

RuralGuy
03-17-2008, 07:03 AM
Have you looked at the Format() function?

oxicottin
03-17-2008, 07:19 AM
In your query you should have in your date fields criteria:
Between [Forms]![YourForm].[YourFormsStartDateTxtBox] And [Forms]![YourForm].[YourFormsEndDateTxtBox]

Then in a text boxes control source on your report put this to show the date that was chosen:
=Format(Forms!YourFormsName.YourFormsStartDateTxtB oxName,"mmmm dd yyyy") & " - " & Format(Forms!YourForm.YourFormsEndDateTxtBox,"mmmm dd yyyy")
Hope this helps.....

JPW
03-19-2008, 11:26 AM
That works and when I go into print preview it appears as how I want it but when the report is actually printed, all I get is a 'Name?' message in the actual printout where it should be showing the date.

Rich
03-19-2008, 12:25 PM
Keep the form open untill the report prints

oxicottin
03-20-2008, 12:28 PM
Like Rich said you have to have the form open. I open my reports maximized over top my form....:p

Private Sub Report_Open(Cancel As Integer)
DoCmd.Maximize
End Sub