Solved Add Start Date and End Date to Report Header as a Subtitle (1 Viewer)

Local time
Today, 13:30
Joined
Aug 19, 2021
Messages
212
I have a report that runs a query that asks you to select the Start Date and End Date. The report runs correctly and presents the proper information. What I would like to do is to have the dates that I run the report for to appear in the header of the report.

The following report is from 1-Jan-21 to 4-Jan-21
1632255405664.png


Please guide how to do this.

Thank you
 

theDBguy

I’m here to help
Staff member
Local time
Today, 01:30
Joined
Oct 29, 2018
Messages
21,358
When you say the report "asks" for the input dates, are you using a parameter query or a form?
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 04:30
Joined
Feb 19, 2002
Messages
42,981
Use form fields. Have the user enter the two dates on the form, The button to run the report should validate the two dates and then open the report using the dates in the wHERE argument of the OpenReport method. The report itself can reference the form field to display the date.

Use the following as the control source for the start date and the same concept for the end date:
=Forms!YourFormName!txtStartDate
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 04:30
Joined
Feb 19, 2002
Messages
42,981
That will work but using parameters rather than form field references is problematic. For example, if you open the report in preview, you are prompted for the variables. If you then print the report, you are prompted again. That doesn't happen with form field references.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 08:30
Joined
Sep 12, 2006
Messages
15,614
you could have a textbox on your report bound to =reportdatestring()

Have a module like this

Code:
public reportdates(2) as date

function readreportdates(choose) as date
readreportdates = reportdate(choose)
end function

function reportdatestring as string
reportdatestring = "Report for dates from " & format(readreportdates(1),"mm/dd/yyyy") & " and " & format(readreportdates(2),"mm/dd/yyyy")
end function

then before you open the report simply this
Code:
reportdates(1) = #8/1/2021# 'or read it from a data picker, etc
reportdates(2) = #8/31/2021# 'or read it from a data picker, etc
 
Local time
Today, 13:30
Joined
Aug 19, 2021
Messages
212
Thank you very much to all of you! My issue has been resolved in Petty Cash Report by Creating TextBox with Control Source =Min([PaymentDate]) and =Max([PaymentDate]).
1632487274707.png

But the same problem is in another report Let me show you its Query:
1632487395816.png

The PaymentDate is not visible in my report . When I am trying to check in show box in my Query It showing me an error "Microsoft Access can't display the field for which you entered Where in the Total row."
1632487564853.png

When I am adding new PaymentDate field with checked show box result of my Query getting change.
Now how can I add Date Range on its title.

1632488258045.png
 
Local time
Today, 13:30
Joined
Aug 19, 2021
Messages
212
You could just include the payment date as a detail column, but make it not visible.
Yes because Its the some of different dates by Head Of Account wise. But PaymentDate field was necessary because I want this report for a specific date range. And I also want that date range to show on the top of my report.
 

Users who are viewing this thread

Top Bottom