473,385 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Auto populating a user defined date range to a report

Hello,

Is there any way to auto populate the user defined date range into a report? I currently have the criteria "Between [StartDate] And [EndDate]" for a date range field. This prompts the user to enter a date range before the report is visible.

Is it possible to capture this date range and display it on the report?

I am using Access 97

Thanks!
Dec 5 '07 #1
7 2831
BradHodge
166 Expert 100+
I would take the criteria out of your query and instead attach the code (below) to a button on a form. This should do what you are looking for.

Hollar if you have questions.

Brad.

Expand|Select|Wrap|Line Numbers
  1. Dim strLinkCriteria As String
  2. Dim BeginDate As String
  3. Dim EndDate As String
  4.  
  5. BeginDate = InputBox("What date would you like to start with?")
  6. EndDate = InputBox("What date would you like to end with?")
  7.  
  8. strLinkCriteria = "([DateField] BETWEEN #" & BeginDate & "# AND #" & EndDate & "#)"
  9. DoCmd.OpenReport "ReportName", acViewPreview, , strLinkCriteria
Dec 5 '07 #2
DAHMB
147 100+
As Brad said the best way is to start the report from a form with the criteria in the form as he posted above. Then in your report you just do an expression in the controlbox of the fields that you want to 'auto populate" with the span of dates searched, that point to the fields in the form you opened your search from.
Dec 5 '07 #3
JustJim
407 Expert 256MB
As Brad said the best way is to start the report from a form with the criteria in the form as he posted above. Then in your report you just do an expression in the controlbox of the fields that you want to 'auto populate" with the span of dates searched, that point to the fields in the form you opened your search from.
If you are outside of the USA and/or your regional settings are for other than the US standard MM/DD/YYYY date format, you will have to format your dates into that format for the criteria to do what you want.

Jim
Dec 6 '07 #4
Hello again,

Sorry it took me a while to get back to you - I have managed to setup the date message box (thanks!), however as Jim rightly points out -

If you are outside of the USA and/or your regional settings are for other than the US standard MM/DD/YYYY date format, you will have to format your dates into that format for the criteria to do what you want.
What's the best way of altering the date regional settings?

One other question - my report has dcounts setup. The results of this are suppose to vary depending on the date range selected. However the dcounts are currently staying static and totalling the entire query - rather than the selected date range records. Is there a way I can ensure the dcount is linked to only the records selected by the date range?

Thanks again
Dec 10 '07 #5
JustJim
407 Expert 256MB
Hello again,

Sorry it took me a while to get back to you - I have managed to setup the date message box (thanks!), however as Jim rightly points out -



What's the best way of altering the date regional settings?

One other question - my report has dcounts setup. The results of this are suppose to vary depending on the date range selected. However the dcounts are currently staying static and totalling the entire query - rather than the selected date range records. Is there a way I can ensure the dcount is linked to only the records selected by the date range?

Thanks again
Date/Time regional settings is a Windows thing and if you change it, it will reflect in every programme/application that uses dates and times. Best just to format the date in your search criteria.

Since the entire Domain of your form is limited by the selected date range, you should be able to get away with Count rather than DCount. Otherwilse, make sure the criteria argument of the Dcount reflects the selected date range and that any fields in the criterie argument are contained in the domain argument.

Jim
Dec 10 '07 #6
Thanks Jim.

Unfortunately I couldn't simply use the count function - as I wanted to use some criteria as well. I managed to fix it by using the formula:

Sum(Iif([field]="yes",1,0)

Thanks again for your help - you are super.
Dec 11 '07 #7
JustJim
407 Expert 256MB
Thanks Jim.

Unfortunately I couldn't simply use the count function - as I wanted to use some criteria as well. I managed to fix it by using the formula:

Sum(Iif([field]="yes",1,0)

Thanks again for your help - you are super.
Ahh the dreaded Iif, well sometimes you just gotta.

Thanks for the kind words, but I assure you I get more questions answered than I answer.

Jim
Dec 11 '07 #8

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

Similar topics

11
by: Mr. Smith | last post by:
Hello all, My code can successfully open, write to, format and save several worksheets in a workbook then save it by a given name, close and quit excel. My problem is that if I try and do it...
0
by: B | last post by:
Using Access2000, the sample code below is what I have been modifying and working on since the past week and I could not get it to work properly. What I wanted to accomplish: 1) read from a...
1
by: shobhit_shanker | last post by:
Here are the relevant "givens" to my problem... Form: frmLaunchRpt - Text Box: txtAsOfDate - Check Box: chkLogEval - Command Button: cmdLaunchRpt Report: rptEvaluation - Text Box:...
3
by: Mark Richards | last post by:
I have this code behind a report (same report as previous post); Sub Report_Open(Cancel As Integer) DoCmd.OpenForm "Report Date Range", , , , , acDialog, "Activity By Location" If Not...
4
by: the hotshot | last post by:
hello, this seems to be a hard question so far and noone has been able to help with this. is it possible to have access start an autonumber with a prefix according to the year when the data is...
2
by: Sara | last post by:
I have followed instructions on the http://allenbrowne.com/tips.html for limiting a report to a date range. At the bottom there is a note that says You will end up using this form for all sorts...
19
by: ali3n8 | last post by:
Hello I have attempted to create a date range report from a query called qrycustomerinformation. The field that contains the value of my date is called Followup. When i run a report on this it is...
12
smithj14
by: smithj14 | last post by:
I have a form to enter start and end dates then select a worker name to filter a report. This all works fine and when the report is open in preview mode it shows the date range in the txtboxes on the...
1
by: disney86 | last post by:
I am setting up Forms in Access 08. I have a form which when opened will auto insert the current time and current date. I need to be able to allow the user to set up paramaters to auto select a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.