How cab we add date selection on the report

hfsitumo2001

Member
Local time
Today, 11:07
Joined
Jan 17, 2021
Messages
394
Hello,

This is my selection date in my query: Between [Forms]![frmReportselection]![txtstDate] And [forms]![frmReportselection]![txtEndate].

My question is how can we have date from the above txtstDate and the txtEndate, because in the report header I will put Report selected from txtstDate to txtEndate. So in the report the date range of the report.

Thank you.

Frank
 
Pass them in as OpenArgs?
Or put them in the record source as expressions?
 
in the query add the form fields:

DteRng: [Forms]![frmReportselection]![txtstDate] & " to " & [forms]![frmReportselection]![txtEndate].

then put field: [DteRng] on the report
 
Instead of having a daisy chain of reliance, make your objects independent of each other and use VBA to tie your database together.

Remove the user-supplied criteria from your query. Add a control to your report labeled SubTitle and set its caption to 'Showing All Records'. Then on your form it sounds like you are using DoCmd.OpenReport (https://learn.microsoft.com/en-us/office/vba/api/access.docmd.openreport) to open your report. One of the arguments it takes is a filter string which allows you to pass criteria to it so it only opens to the records that meet that criteria. Use that to filter your report appropriately. In the VBA, right after you run the DoCmd.OpenReport you can reference the subtitle on the report and change the caption to the criteria you used (e.g. 'Showing Records From 1/1/2022 - 2/1/2022').

Now you can reuse that query as needed, you can reuse the report as needed, you can allow users to open the report to no date criteria, you can even add more criteria elements (By SalesPerson, By Color, By Cost, etc.) for your users to input.
 
in the query add the form fields:

DteRng: [Forms]![frmReportselection]![txtstDate] & " to " & [forms]![frmReportselection]![txtEndate].

then put field: [DteRng] on the report
Thank you Ranman256, I will try it.

Frank
 
or you can put a Unbound Textbox on your Report for those "inclusive dates".
the Control Source of the textbox:

= [Forms]![frmReportselection]![txtstDate] & " to " & [forms]![frmReportselection]![txtEndate]
 
OR
put a Lable whose Caption would be:
[Forms]![frmReportselection]![txtstDate] & " to " & [forms]![frmReportselection]![txtEndate]

yourLable.Caption = [Forms]![frmReportselection]![txtstDate] & " to " & [forms]![frmReportselection]![txtEndate]
 
OR
put a Lable whose Caption would be:
[Forms]![frmReportselection]![txtstDate] & " to " & [forms]![frmReportselection]![txtEndate]

yourLable.Caption = [Forms]![frmReportselection]![txtstDate] & " to " & [forms]![frmReportselection]![txtEndate]
Isn't that what arnel suggested, just using a textbox instead. Logic is excatly the same though?
 
or you can put a Unbound Textbox on your Report for those "inclusive dates".
the Control Source of the textbox:

or you can put a Unbound Textbox on your Report for those "inclusive dates".
the Control Source of the textbox:

= [Forms]![frmReportselection]![txtstDate] & " to " & [forms]![frmReportselection]![txtEndate]
I tried it Arnel, but it requested name showing this in the textbox: #Name

Okay Arnel, it works for me now. Again thank you very much

Frank
 

Users who are viewing this thread

Back
Top Bottom