Passing a filtered form record set to a report

Keith Nichols

Registered User.
Local time
Today, 09:35
Joined
Jan 27, 2006
Messages
431
There are a few threads around covering this area (and I have posted on a couple) but none of them seem to be quite what I need (or I haven’t understood them :( ) and I have been going round in circles a bit.

I have:
• A form that is filtered by 1 of 6 VBA filters called by Select Case code on a combo box. The filters are not all on the same fields
• A report that is based on the same fields/tables as the form with no criteria set in the report query
• A button on the form that launches the report

Amongst other things, I have tried setting the report record set using
Code:
Set Me.Recordset = Forms!fdlgPrjDetails.Recordset
Which the VBA help says applies to reports but it doesn’t work.

I thought maybe I could convert my filters to SQL in the VBA and then send them with the docmd.openreport but I’m not entirely sure how to do this.
I got tied in knots trying to create a “where” as my filters are not the same.

I really would appreciate some pointers for the most sensible way forward. At least if I know I’m on the right path I can persevere without the worry that I am wasting my time. :)

Pls find attached a copy of the db for reference


========================================================================================

I think Ihave found the solution on another thread:
http://www.access-programmers.co.uk/forums/showthread.php?t=110185&highlight=record+set+form+filter

It looks like the bit I wasn't getting is that the where clause can be set to me.filter to call the report only for the filtered form.

I will update the the posted db and post back when I get the chance - probably next week.
========================================================================================
 

Attachments

Last edited:
PHP:
Set Me.Recordset = Forms!fdlgPrjDetails.Recordset

looks like VB to me. I don't think either of your references are valid VBA.


Try something like

PHP:
Me.recordsource = Forms!fdlgPrjDetails.recordsource
 

Users who are viewing this thread

Back
Top Bottom