472,342 Members | 1,436 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,342 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 1594
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...

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.