Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
| Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 19th, 2006, 06:05 PM
Authorized User
 
Join Date: May 2006
Location: , BC, Canada.
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default Filter vs WhereCondition in Report Access

Hi, When I open a report, I want to use the filter in current Form.
Code:
If me.flterOn then
strFilter=Me.Filter
end if
Docmd.OpenReport myReport,acPreview,strFilter
The report displays all record regardless my filter.

If I put the strFilter in WhereCondition clause, it works.
Code:
Docmd.OpenReport myReport,acPreview,,strFilter
Could you tell me why? Thanks.

??VBA and ACCESS ??
__________________
??VBA and ACCESS ??
 
Old May 19th, 2006, 06:16 PM
Friend of Wrox
 
Join Date: Oct 2004
Location: Clinton, UT, USA.
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Someone else will probably have a better answer than me, but from what I understand, the Filter part of the OpenReport command refers to a named filter - not sure what that is though.

The where command is entered into the Filter property on the Report.

HTH

Mike

Mike
EchoVue.com
 
Old May 19th, 2006, 06:52 PM
Authorized User
 
Join Date: May 2006
Location: , BC, Canada.
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Mike. My problem is when I filter on combobox in the form. The report would not recognize this filter.
Table :
tblAsset (as_id, at_id(foreign key))
tblAssetType (at_id, at_name)
Form :
frmAsset( txtAssetID, cmbAssetType)
Report:
rptAsset (txtAssetID, cmbAssetType)

When I set filter on cmbAssetType on frmAsset, I am not able to carry this filter to the report by using above code.
Access pops up windows "Enter Parameter Value: Lookup_cmbAssetType.at_name"

Any solution?

Sorry. forgot to mention the Row source for cmbAssetType is SELECT * FROM tblAssetType; Bound column 1, but display column 2 only.

??VBA and ACCESS ??
 
Old May 19th, 2006, 07:25 PM
Friend of Wrox
 
Join Date: Oct 2004
Location: Clinton, UT, USA.
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

So you're setting the filter based on the combobox, right?

When I do this, I set up the combo box, then when I run the code for the report, I do something like...

DoCmd.OpenReport "My Report", acPreview,, "AssetID=" & txtAssetID & " AND AssetType=" & cmbAssetType

Does that help out at all?

Mike




Mike
EchoVue.com
 
Old May 23rd, 2006, 02:57 PM
Authorized User
 
Join Date: May 2006
Location: , BC, Canada.
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes. You got my point. But the solution seems not practical because I have more 20 fields in the form and 5 of them are combbox on the form. When I run the report, the user may have a filter that consists of more than 2 fields. If I can not pass Me.filter to the report, I have to analyze the filter and re-generate a WhereCondition and it seems no sense.

What do you think?


??VBA and ACCESS ??




Similar Threads
Thread Thread Starter Forum Replies Last Post
Access Report Filter rfurman1161 Access 10 March 22nd, 2006 09:14 PM
How to filter Crytal report ? abdusalam VB How-To 0 June 24th, 2004 01:44 AM
Filter Report TonyG Access VBA 6 February 11th, 2004 11:56 AM
Filter Report using value Box DBoulos Access VBA 6 December 17th, 2003 08:04 PM
Filter Report by a formulate field Tere Crystal Reports 0 December 1st, 2003 07:10 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.