By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,327 Members | 2,627 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,327 IT Pros & Developers. It's quick & easy.

Range dates on Acess report

P: 13
I am running a report and using date ranges. I will like that when I run the report to see printed those date ranges that I enter on the parameter. Could someone assist me or direct me in the proper direction?
Thank you
Aug 22 '06 #1
Share this Question
Share on Google+
8 Replies


MMcCarthy
Expert Mod 10K+
P: 14,534
If your date range parameters are being entered via a queries criteria you can't really do this. However, if you are entering your date range parameters on a form you can set up a text field on the report with a source something like this:

=Forms![FormName]![DateFrom] & " to " & Forms![FormName]![DateTo]

I am running a report and using date ranges. I will like that when I run the report to see printed those date ranges that I enter on the parameter. Could someone assist me or direct me in the proper direction?
Thank you
Aug 22 '06 #2

P: 13
Could you tell me how or were do I set the parameters from the report, so the dates can be printed on the report.

Thank you very much
Jose
Aug 22 '06 #3

MMcCarthy
Expert Mod 10K+
P: 14,534
Create an empty form and open in design view.

Put two textboxes on the form. Put appropriate label names on the textboxes.

Right click on the first textbox and go down to the bottom of the list to Properties. The first tab is the list of Format Properties and the first item on the list is format. Change this to an appropriate date format. The standard is:

Short Date

Next click on the Data tab and go down to the Default Value property. Type in

Now()

This will set the date to todays date when the form opens.

Then go to the Other tab and change the Name property to

DateFrom

Do the same for the second text box except name it

DateTo

Then add a command button to the report. Use the wizard to indicate that you want to open the relevant report to show all records. (Don't forget to remove the Criteria from the Reports query that you are currently using to set the date range.

When the wizard closes go to the properties of the command button (right click). Go to the event tab and click on the button with the dots beside the On Click event.

The code should look something like this:

Private Sub Command1_Click()
Dim stDocName As String

stDocName = "Report Name"
DoCmd.OpenReport stDocName, acViewPreview

End Sub

You need to change it so it looks like this:

Private Sub Command1_Click()
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Report Name"
stLinkCriteria = "[DateField] BETWEEN " & Me.DateFrom & " AND " & Me.DateTo
DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria

End Sub

Close and save the form with an appropriate name. Set it so that this form now opens instead of the report when the user wants to view/print the report.

As before add a textbox to your report as described in previous post.




Could you tell me how or were do I set the parameters from the report, so the dates can be printed on the report.

Thank you very much
Jose
Aug 22 '06 #4

100+
P: 179
I'm sorry McCarthy, maybe I misunderstood what JoseCruz was looking for. But you said that you can't do this if using a query.

If you were to open the query in design mode, drag the date field down, and then in the criteria box underneath, type:

Between [Enter Start Date] and [Enter End Date]

This will prompt you for your 2 dates when opening a form that is tied to this query.

Jose, is this what you wanted to do?

comteck
Aug 23 '06 #5

MMcCarthy
Expert Mod 10K+
P: 14,534
Hi Comtech

The problem was that JoseCruz wanted to be able to then use the dates inputed by the user to print a date range on the report.

I'm sorry McCarthy, maybe I misunderstood what JoseCruz was looking for. But you said that you can't do this if using a query.

If you were to open the query in design mode, drag the date field down, and then in the criteria box underneath, type:

Between [Enter Start Date] and [Enter End Date]

This will prompt you for your 2 dates when opening a form that is tied to this query.

Jose, is this what you wanted to do?

comteck
Aug 23 '06 #6

100+
P: 179
That's right... and using the query should work... if I am correct in thinking this is what JoseCruz is looking for.

Anyhow, Jose... you're welcome to try either method you choose, and use the one that works best for your application.

Good Luck.
comteck
Aug 23 '06 #7

P: 13
mmccarthy and comteck I thank you guys so much for your help. I tried the first method and I believe this is what I need. I am just glad that I have great responces. For a minute I thought I was going to give up. Once again thank you so much.
Jose
Aug 24 '06 #8

P: 1
Gentelman,

In the same quote, I wrote a VB app (not VBA) that requires the user to enter a date range TO and FROM then it connects to and SQL DB and outputs some reports in Access.

How can I pass the dates TO and FROM from the VB app to the access reports?

Thanks for your help.


Create an empty form and open in design view.

Put two textboxes on the form. Put appropriate label names on the textboxes.

Right click on the first textbox and go down to the bottom of the list to Properties. The first tab is the list of Format Properties and the first item on the list is format. Change this to an appropriate date format. The standard is:

Short Date

Next click on the Data tab and go down to the Default Value property. Type in

Now()

This will set the date to todays date when the form opens.

Then go to the Other tab and change the Name property to

DateFrom

Do the same for the second text box except name it

DateTo

Then add a command button to the report. Use the wizard to indicate that you want to open the relevant report to show all records. (Don't forget to remove the Criteria from the Reports query that you are currently using to set the date range.

When the wizard closes go to the properties of the command button (right click). Go to the event tab and click on the button with the dots beside the On Click event.

The code should look something like this:

Private Sub Command1_Click()
Dim stDocName As String

stDocName = "Report Name"
DoCmd.OpenReport stDocName, acViewPreview

End Sub

You need to change it so it looks like this:

Private Sub Command1_Click()
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Report Name"
stLinkCriteria = "[DateField] BETWEEN " & Me.DateFrom & " AND " & Me.DateTo
DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria

End Sub

Close and save the form with an appropriate name. Set it so that this form now opens instead of the report when the user wants to view/print the report.

As before add a textbox to your report as described in previous post.
Sep 5 '06 #9

Post your reply

Sign in to post your reply or Sign up for a free account.