How cab we add date selection on the report (1 Viewer)

hfsitumo2001

Member
Local time
Today, 13:34
Joined
Jan 17, 2021
Messages
365
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
 

Gasman

Enthusiastic Amateur
Local time
Today, 21:34
Joined
Sep 21, 2011
Messages
14,317
Pass them in as OpenArgs?
Or put them in the record source as expressions?
 

Ranman256

Well-known member
Local time
Today, 16:34
Joined
Apr 9, 2015
Messages
4,337
in the query add the form fields:

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

then put field: [DteRng] on the report
 

plog

Banishment Pending
Local time
Today, 15:34
Joined
May 11, 2011
Messages
11,646
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.
 

hfsitumo2001

Member
Local time
Today, 13:34
Joined
Jan 17, 2021
Messages
365
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
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 04:34
Joined
May 7, 2009
Messages
19,245
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]
 

alcalde

New member
Local time
Today, 22:34
Joined
Oct 31, 2022
Messages
9
OR
put a Lable whose Caption would be:
[Forms]![frmReportselection]![txtstDate] & " to " & [forms]![frmReportselection]![txtEndate]

yourLable.Caption = [Forms]![frmReportselection]![txtstDate] & " to " & [forms]![frmReportselection]![txtEndate]
 

Gasman

Enthusiastic Amateur
Local time
Today, 21:34
Joined
Sep 21, 2011
Messages
14,317
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?
 

hfsitumo2001

Member
Local time
Today, 13:34
Joined
Jan 17, 2021
Messages
365
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

Top Bottom