Print Report based on form value (1 Viewer)

jboyle

New member
Local time
Today, 05:54
Joined
Nov 18, 2000
Messages
53
I have several forms that I would like to print a report from. The data on the different forms is common, so I want to have just one report that prints based on the form that is open. I put a button on each form to open a report called MY REPORT. I put a query behind the report that had the following statement in the criteria box under [process name].
Me![Process Name]

I thought the ME! statement would get the name of the form and what was selected in the [Process Name] field.

Is there a way to have several forms and just one common report to print based on the open form???
Thanks in advance - John
 

Alexandre

Registered User.
Local time
Today, 11:54
Joined
Feb 22, 2001
Messages
794
I am not sure I understand correctly your situation.
The data on the different forms is common
What do you mean?

-Do they display basically the same thing and are based on the same recordsource? You would be better served offering a filtering feature for a unique form then.

Applying to a report the filter applied to a form is easy:
DoCmd.OpenReport YourReportName, acViewPreview, , Me.Filter
will do for example.


-If they are not based on the same recordsource, you need to change 'on the fly' the recordsource of the report you want to open and eventually its filter, based on the form the report was called from.

Changing the recordsource of your report can perfectly be done but is more tricky. You have to make sure that all fields used in your report exist and have the same name in the different recordsources you will use. Otherwise, you would get errors on opening your reports.

Expand a bit on your situation so that we can provide more precise help.
 
Last edited:

SteveM

Registered User.
Local time
Today, 05:54
Joined
May 27, 2002
Messages
11
Hi,

I think the criteria field in the query needs to read something like this:-

Forms![frmName]![Process Name]

HTH

Steve
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 00:54
Joined
Feb 19, 2002
Messages
43,565
If you want to run the same report from several forms, you cannot specify the criteria in the report's query by referring to a form field. Instead, use the "where" argument of the OpenReport Method.
 

Users who are viewing this thread

Top Bottom