473,387 Members | 1,573 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,387 software developers and data experts.

how to restrict date range that appears on a report?

Could anyone tell me how to restrict the date range for items that
appear on a report? Old items from previous years appear on the
report. I was asked to have only this year's items (and beyond) listed
on the report. How do I do that?
Dec 4 '07 #1
3 2999

<km*******@hotmail.comschreef in bericht news:0d**********************************@i29g2000 prf.googlegroups.com...
Could anyone tell me how to restrict the date range for items that
appear on a report? Old items from previous years appear on the
report. I was asked to have only this year's items (and beyond) listed
on the report. How do I do that?
Have a look at the recordsource for the report.
This wil probably be a query. You will need to restrict the dates there.
Hint: Look for 'Criteria'

Arno R
Dec 4 '07 #2
On Tue, 4 Dec 2007 06:51:32 -0800 (PST), km*******@hotmail.com wrote:
Could anyone tell me how to restrict the date range for items that
appear on a report? Old items from previous years appear on the
report. I was asked to have only this year's items (and beyond) listed
on the report. How do I do that?
There are several methods.
Either ...
1) Create a query that is used as the record source for the form.
As criteria on the query's Date field, write:
>= DateSerial(Year(Date()),1,1)
The above criteria will return all records for this and 'future'
years.

Or...

2) Open the report directly from a form command button:

DoCmd.OpenReport "ReportName", acViewPreview, , "[DateField] >= #" &
DateSerial(Year(Date),1,1) & "#"

In this case you do not need to create the query.

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Dec 4 '07 #3
I tend to open a DateEntry form on openeing the report to enter the date
parameters

Private Sub Report_Open(Cancel As Integer)

Dim StgFilter As String

DoCmd.OpenForm "DateEntry"

CheckDateEntryClosed:
If IsLoaded("DateEntry") Then
Call apWait(5, False) ' Wait 5 seconds
GoTo CheckDateEntryClosed
End If

StgFilter = "MemJoinDate" & DateField
Me.Filter = StgFilter
Me.FilterOn = True

End Sub

The date form has start date and end date, and when you press the OK button,
the following code runs

Function DateRange(Frm As Form) As String

Dim strWhere As String 'Where condition for OpenReport.
Dim EndDate As Date

Const conDateFormat = "\#dd\/mmm\/yyyy\ Hh:Nn:Ss#"

If YrID 0 Then ' Year selected
EndDate = ELookup("YearEnd", "Year", "YearID = " & YrID)
EndDate = DateAdd("d", 1, EndDate) ' Add 1 day
EndDate = DateAdd("s", -1, EndDate) ' Subtract 1 second
1 day
strWhere = " Between " & Format(ELookup("YearStart", "Year", "YearID
= " & YrID), conDateFormat)
strWhere = strWhere & " And " & Format(EndDate, conDateFormat)
GoTo DateRange_Exit
End If

If IsNull(Frm!txtStartDate) Then
If Not IsNull(Frm.txtEndDate) Then 'End date, but no start.
strWhere = DateField & " < " & Format(Frm.txtEndDate,
conDateFormat)
End If
Else
If IsNull(Frm.txtEndDate) Then 'Start date, but no End.
strWhere = DateField & " " & Format(Frm.txtStartDate,
conDateFormat)
Else 'Both start and end dates.
strWhere = DateField & " Between " & Format(Frm.txtStartDate,
conDateFormat) _
& " And " & Format(Frm.txtEndDate, conDateFormat)
End If
End If

DateRange_Exit:
DateRange = strWhere
DateField = strWhere

End Function
<km*******@hotmail.comwrote in message
news:0d**********************************@i29g2000 prf.googlegroups.com...
Could anyone tell me how to restrict the date range for items that
appear on a report? Old items from previous years appear on the
report. I was asked to have only this year's items (and beyond) listed
on the report. How do I do that?

Dec 4 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Garyrek | last post by:
Hi I have a requirement where I need to make a report for each auto dealer how many hits they got on specified date range, so for each car detail page I increment the counter and total it while...
1
by: irfanali | last post by:
Hallo All, This is a Tool i m tryin to develop at work. I will explain how it works and then the Q I download a report from my ERP Tool on a daily basis and upload it into the Access Tool....
1
by: ramaswamynanda | last post by:
Hello all, I have a timesheet details table . I am trying to run the following query against it. SELECT ., . FROM timesheetdetails WHERE Format(,'dd/mm/yyyy') between '01/01/2007' and...
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...
7
by: dozingquinn | last post by:
Hello, Is there any way to auto populate the user defined date range into a report? I currently have the criteria "Between And " for a date range field. This prompts the user to enter a date...
1
by: JLeitner08 | last post by:
I have a report that has criteria in the query, that will ask for a starting and ending date, a location, and a type. Alone, the parameters work great for the report. Now I want to add a subreport...
6
by: dschiewe | last post by:
Hello, This is my first time posting on here so I hope I don't ramble too much. I have a complex database that a co-worker and I created 2 years ago and that I have been adding to since then. The...
3
by: 6afraidbecause789 | last post by:
If able, can someone please help make a Where clause that strings together IDs in a multi-select listbox AND includes a date range. I wasn’t thinking when I used the code below that strings...
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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
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.