473,385 Members | 2,180 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.

Help with report filter

I am using the code below to filter a report:

Private Sub Set_Filter_Click()
If Me![BeginDate] And Me![EndDate] <> "" Then
If Application.CurrentProject.AllReports("rptDailyOut put").IsLoaded
Then
DoCmd.Close acReport, "rptDailyOutput"
DoCmd.OpenReport "rptDailyOutput", acViewPreview, , "[MyDate]
Between #" & Format(Me![BeginDate], "mm/dd/yy") & "# and #" &
Format(Me![EndDate], "mm/dd/yy") & "#"
Else
DoCmd.OpenReport "rptDailyOutput", acViewPreview, , "[MyDate]
Between #" & Format(Me![BeginDate], "mm/dd/yy") & "# and #" &
Format(Me![EndDate], "mm/dd/yy") & "#"
End If
Else
MsgBox "You must enter a Start Date & End Date", vbOKOnly
End If
End Sub

I have added a new combo-box on the filter form called [DC]
This combo box row source type is "value list" and the source is:
"ALL";"VDC";"QDC"

How can I include [DC] in the code above? (where it is a required
selection)
I have tried with no success.
Nov 12 '05 #1
4 1643
On 15 Jan 2004 01:15:33 -0800, na**************@hotmail.com (Nathan
Bloomfield) wrote:
I am using the code below to filter a report:

Private Sub Set_Filter_Click()
If Me![BeginDate] And Me![EndDate] <> "" Then
If Application.CurrentProject.AllReports("rptDailyOut put").IsLoaded
Then
DoCmd.Close acReport, "rptDailyOutput"
DoCmd.OpenReport "rptDailyOutput", acViewPreview, , "[MyDate]
Between #" & Format(Me![BeginDate], "mm/dd/yy") & "# and #" &
Format(Me![EndDate], "mm/dd/yy") & "#"
Else
DoCmd.OpenReport "rptDailyOutput", acViewPreview, , "[MyDate]
Between #" & Format(Me![BeginDate], "mm/dd/yy") & "# and #" &
Format(Me![EndDate], "mm/dd/yy") & "#"
End If
Else
MsgBox "You must enter a Start Date & End Date", vbOKOnly
End If
End Sub

I have added a new combo-box on the filter form called [DC]
This combo box row source type is "value list" and the source is:
"ALL";"VDC";"QDC"

How can I include [DC] in the code above? (where it is a required
selection)
I have tried with no success.


You didn't tell us the name of the field to be filtered using [DC]!!!
I'll assume there is a field called [SomeField] in the table and it is
Text DataType.
Just add the criteria at the end of your existing where clause, after
removing the existing final ".

"[MyDate] Between #" & Format(Me![BeginDate], "mm/dd/yy") & "# and #"
& Format(Me![EndDate], "mm/dd/yy") & "# AND [SomeField] = '" & Me![DC]
& "'"

--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.
Nov 12 '05 #2
> Just add the criteria at the end of your existing where clause, after
removing the existing final ".

"[MyDate] Between #" & Format(Me![BeginDate], "mm/dd/yy") & "# and #"
& Format(Me![EndDate], "mm/dd/yy") & "# AND [DC] = '" & Me![DCselect]
& "'"

When using the code above I get the following error:

"Microsoft Access can't find the field "|" referred to in your expression

I have confirmed the names of the fields & they are correct.
Nov 12 '05 #3
On 15 Jan 2004 14:39:32 -0800, na**************@hotmail.com (Nathan
Bloomfield) wrote:
Just add the criteria at the end of your existing where clause, after
removing the existing final ".

"[MyDate] Between #" & Format(Me![BeginDate], "mm/dd/yy") & "# and #"
& Format(Me![EndDate], "mm/dd/yy") & "# AND [DC] = '" & Me![DCselect]
& "'"

When using the code above I get the following error:

"Microsoft Access can't find the field "|" referred to in your expression

I have confirmed the names of the fields & they are correct.

Nathan,

The correct syntax is
"[FieldInTheTableToBeSearched] = '" & Me![ControlOnForm] & "'"

According the this post, [DCselect] is the combo on the form; [DC] is
the field in the table.

You originally posted:I have added a new combo-box on the filter form called [DC]
This combo box row source type is "value list" and the source is:
"ALL";"VDC";"QDC"

In other words, the control [DC] is the one on the filter form that
contains the 3 possible words, of which only one is wanted to be
returned.
You didn't post the name of the field in the table.

I wrote:
& "# AND [SomeField] = '" & Me![DC] & "'"

You wrote:
& "# AND [DC] = '" & Me![DCselect] & "'"

You mixed the control on the form ([DC]) with the field in the table
([DCSelect]).

You should have written:
"# AND [DCSelect] = '" & Me![DC] & "'"
--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.
Nov 12 '05 #4
> Just add the criteria at the end of your existing where clause, after
removing the existing final ".

"[MyDate] Between #" & Format(Me![BeginDate], "mm/dd/yy") & "# and #"
& Format(Me![EndDate], "mm/dd/yy") & "# AND [DC] = "'" & Me![DCSelect]
& "'"


Hi Fred,

I should have mentioned that I changed the control on the form from DC
to DCselect to avoid confusion with the field DC on the report.

Also, I added a quotation mark (") after the [DC] = as I was getting
an error.

Thanks for your help, any more advice would be much appreciated as
this problem I've just encountered is holding back a project I've been
working on for weeks.

Regards,

Nathan
Nov 12 '05 #5

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

Similar topics

5
by: MGFoster | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I've converted an ACC97 .mdb file to an ACC2K2 .adp. A report that worked in ACC97 doesn't work in ACC2K2. Report setup: ACC97 ...
1
by: Simon Matthews | last post by:
Hope someone can help an Access beginner! I've just started keeping my surgical logbook on access and it's a simple flat-file affair. I have created several queries that will list cases...
1
by: lorirobn | last post by:
Hi, I have a report that works just fine. Now I would like to add the capability to choose selection criteria to limit what is displayed. I created several reports that do this, but they used...
3
by: dad | last post by:
I am building a database to track the maintenance records on a fleet of cars. I need to run a report on that will display data based on whether a box is checked or not (i.e. all cars that have the...
4
by: Wook | last post by:
Ok I got a set of Forms Reports etc it goes like this Reports Form Passes a Filter to the report for the needed results The filter it passes along is fine except one problem I need a way for the...
1
by: access baby | last post by:
Hi Below mention is the reply from Salad on my query i created a crosstab query and form not based on any table of qurey but this doesnt work . I somehow have missed something actually i have too...
1
by: dfw1417 | last post by:
I have used a query and report filter to return records related to a specific account id. I want to print a report including only the latest 6 records out of the set returned by the record filter. I...
0
by: Andrew Meador - ASCPA, MCSE, MCP+I, Network+, A+ | last post by:
I am running Access 2007. I have a report that I want to filter. I can go into Advanced...Advanced Filter/Sort... and setup a filter that works fine on the report when I apply it. When in this...
0
by: Andrew Meador - ASCPA, MCSE, MCP+I, Network+, A+ | last post by:
I am running Access 2007. I have a report that I want to filter. I can go into Advanced...Advanced Filter/Sort... and setup a filter that works fine on the report when I apply it. When in this...
3
by: BarbaraB | last post by:
Is there anyway of returning the value of an option group (in access 2003) back to what it was before any entry was made? I frequenty find people are wishing to remove there answer but with an...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
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...

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.