Printing Report from macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to create a macro which I can use as a button in the form view
toolbar. I want to be able to enter my data on the form, and then print only
the corresponding report by hitting the button. I can get it to print, but
what do I do to only print current report?
 
Mark,

I assume you are using an OpenReport action in the macro? If so, use
the Where Condition argument of the macro to restrict the printed report
to the form's current record. Either that, or use a criteria in the
query that the report is based on to restrict the printed report to the
form's current record.
 
Yes I am trying to use the OpenReport action. I am having trouble using the
expression builder to open only the corresponding report. Can you suggest a
place I can look up more info on how to use it?
 
Mark,

I assume your form has a field which uniquely identifies the record.
Since you didn't mention, let's suppose it's called ID, and that this
field is also include in the report. So, in the Where Condition
argument of the OpenReport action in your macro, you would put something
like this...
[ID]=[Forms]![NameOfYourForm]![ID]
 
Yes I was just using the default title of "ID". Sorry I am kind of new to
this and didnt specify what I was doing very well. But I tried your advice
and it worked perfectly. Thank you soooo much.

Mark

Steve Schapel said:
Mark,

I assume your form has a field which uniquely identifies the record.
Since you didn't mention, let's suppose it's called ID, and that this
field is also include in the report. So, in the Where Condition
argument of the OpenReport action in your macro, you would put something
like this...
[ID]=[Forms]![NameOfYourForm]![ID]

--
Steve Schapel, Microsoft Access MVP

Yes I am trying to use the OpenReport action. I am having trouble using the
expression builder to open only the corresponding report. Can you suggest a
place I can look up more info on how to use it?
 
One more question. I have the macro working properly,
but the only problem is that it runs everytime I open up
the form, when I only want it to run when I press the
command button on the form. I have it set on "Print
Preview" when it runs. So when I open the form, the
print preview pops up, hidden in the background. How can
I resolve this problem?

Mark
-----Original Message-----
Yes I was just using the default title of "ID". Sorry I am kind of new to
this and didnt specify what I was doing very well. But I tried your advice
and it worked perfectly. Thank you soooo much.

Mark

Steve Schapel said:
Mark,

I assume your form has a field which uniquely identifies the record.
Since you didn't mention, let's suppose it's called ID, and that this
field is also include in the report. So, in the Where Condition
argument of the OpenReport action in your macro, you would put something
like this...
[ID]=[Forms]![NameOfYourForm]![ID]

--
Steve Schapel, Microsoft Access MVP

Yes I am trying to use the OpenReport action. I am having trouble using the
expression builder to open only the corresponding report. Can you suggest a
place I can look up more info on how to use it?
.
 
Mark,

It seems to me that this is to do with the event where you have the
macro assigned. It should be on the On Click event property of the
command button. It sounds like you may have it on the On Open or On
Load or On Current event property of the form itself.
 
Well I checked out the macro and its actually fine. What
I did was delete the command button and the macro,
created a new macro under a different name and inserted a
new command button. My problem seems to lie within the
form. I say this because now even though I have deleted
the old command button AND the old macro itself,
everytime I open the form now an error message pops up
saying it cannot locate the macro with the old form
name. So apparently I it is still trying to run the
macro somewhere on the form. How can I figure out where
this is so I can delete it?

Mark
 
Back
Top