Report Selection Criteria

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am a novice Access user and it has been some time since last using it. My
question is; How do you input selection criteria for displaying a report by
date range? I have done it before and don't recall it as being difficult.
Just not coming to me.
 
Allen,

Thanks for the reply. Very helpful. I decided to also try your method 2 and
having trouble with:

Dim strReport As String 'Name of report to open.
Dim strField As String 'Name of your date field.
Dim strWhere As String 'Where condition for OpenReport.
Const conDateFormat = "\#mm\/dd\/yyyy\#"

The name of report is Practice Stats and The field name is Date. I don't
understand 'where condition from report. What should the entry look like?
Thanks
 
Hmm. Date is a reserved word in VBA, and so not a good idea for field names.
You may be able to get around it by adding square brackets. The report name
contains a space, it will be need square brackets in the name as well.

The code will therefore start:
strReport = "[Practice Stats]"
strField = "[Date]"
and the rest exactly as in the article.

The Debug.Print line should generate something like this for the Where
string:
[Date] > #5/5/2005#
 
I am using Method 2 as well. Is there a way to default the start date to the
date entered at 10 PM and the end date to the date entered at 8 AM? I still
want to be able to enter just the two dates, but the first date should always
be 10 PM and the second on always 8 AM.

Thanks, Mary

Allen Browne said:
Hmm. Date is a reserved word in VBA, and so not a good idea for field names.
You may be able to get around it by adding square brackets. The report name
contains a space, it will be need square brackets in the name as well.

The code will therefore start:
strReport = "[Practice Stats]"
strField = "[Date]"
and the rest exactly as in the article.

The Debug.Print line should generate something like this for the Where
string:
[Date] > #5/5/2005#

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

ttaylor said:
Allen,

Thanks for the reply. Very helpful. I decided to also try your method 2
and
having trouble with:

Dim strReport As String 'Name of report to open.
Dim strField As String 'Name of your date field.
Dim strWhere As String 'Where condition for OpenReport.
Const conDateFormat = "\#mm\/dd\/yyyy\#"

The name of report is Practice Stats and The field name is Date. I don't
understand 'where condition from report. What should the entry look like?
Thanks
 
Sure. Change the constant declaration to:
Const conDateFormat = "\#mm\/dd\/yyyy hh:nn:ss\#"

Then in the middle of the procedure, use DateAdd() to add the required
number of hours:
Me.txtStartDate = DateAdd("h", 22, Me.StartDate)
Me.txtEndDate = DateAdd("h", 8, Me.EndDate)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Mary said:
I am using Method 2 as well. Is there a way to default the start date to
the
date entered at 10 PM and the end date to the date entered at 8 AM? I
still
want to be able to enter just the two dates, but the first date should
always
be 10 PM and the second on always 8 AM.

Thanks, Mary

Allen Browne said:
Hmm. Date is a reserved word in VBA, and so not a good idea for field
names.
You may be able to get around it by adding square brackets. The report
name
contains a space, it will be need square brackets in the name as well.

The code will therefore start:
strReport = "[Practice Stats]"
strField = "[Date]"
and the rest exactly as in the article.

The Debug.Print line should generate something like this for the Where
string:
[Date] > #5/5/2005#

ttaylor said:
Allen,

Thanks for the reply. Very helpful. I decided to also try your method 2
and
having trouble with:

Dim strReport As String 'Name of report to open.
Dim strField As String 'Name of your date field.
Dim strWhere As String 'Where condition for OpenReport.
Const conDateFormat = "\#mm\/dd\/yyyy\#"

The name of report is Practice Stats and The field name is Date. I
don't
understand 'where condition from report. What should the entry look
like?
Thanks

:

See:
Limiting a Report to a Date Range
at:
http://allenbrowne.com/casu-08.html


I am a novice Access user and it has been some time since last using
it.
My
question is; How do you input selection criteria for displaying a
report
by
date range? I have done it before and don't recall it as being
difficult.
Just not coming to me.
 
Back
Top