Where Condition for printing

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

Guest

I have built a database and I am wanting to use the macro in the form to
print a report. the report prints just fine, but it prints the entire
report, not just the current page.

I have located the "Where Condition" in the "Open Form" properties of the
macro, but I have no idea what to do from here.

Can anyone give me a step by step on how to fix my problem? (I am not a
programmer, so some of the lango is greek to me)

Thanks,

Paul M
 
I am assuming you have a form with a button on it that is linked to a macro.
This macro already contains the OpenReport command. You can use the
properties of the PrintOut command to print out all pages, or only a specific
range of pages (page 2 through page 2, for example). Add the PrintOut command
immediately after the OpenReport command in your macro. Is that what you're
looking for?

GwenH
Master Certified MOS
 
Thank you for answering,

Yes, I have a button in my form that links to a macro, but what I want it to
do is print only the current page being used, and not the entire report
(which is what it is doing right now). I have clicked on the "Where
Condition" in the "Open Report" properties of the macro, but I am clueless as
to what I need to do.
 
Thank you for answering,

Yes, I have a button in my form that links to a macro, but what I want it to
do is print only the current page being used, and not the entire report
(which is what it is doing right now). I have clicked on the "Where
Condition" in the "Open Report" properties of the macro, but I am clueless as
to what I need to do.

While you can use a macro, it's just as easy to use code. Using code
has the advantage of your being able to include error handling within
the code.
Here is how.

Your table should have a unique prime key field.
In my example it is named [RecordID].

On the command button's property sheet write
[Event Procedure]
on the Click event line.
Then click on the little button with 3 dots that will appear on that
line.
When the code window opens, the cursor will be flashing between 2
already existing lines of code.
Between those 2 lines write:

DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "ReportName", acViewPreview, , "[RecordID] = " &
[RecordID]

The above assumes a [RecordID] field that is a Number Datatype.

If, however, [RecordID] is Text Datatype, then use:

DoCmd.OpenReport "ReportName", acViewPreview, ,"[RecordID] = '" &
[RecordID] & "'"

as the Where clause.

For clarity, the single and double quotes are..
"[RecordID] = ' " & [RecordID] & " ' "
Change [RecordID] to whatever the actual field name is that you are
using.

See VBA Help files for:
Where Clause + Restrict data to a subset of records'
 
The Where condition is only going to filter the report based on the contents
of a particular field. If you add the Where condition to your print macro,
when the report opens it will only contain data that matches the where
condition. Are you trying to select and print certain records only, or a
specific page of the report? And how is the page you want to be print being
selected?

GwenH
 
Oh, so you have a form from which the user can select a record, then you want
to print out the report only for that record. Assuming your report is based
on a query, add the following condition to the column in your query that
you're trying to filter on:

=[Forms]![FormName]![Form_Field_On_Which_to_Filter]

Let me know if that doesn't work.

GwenH
 
I believe I might have fixed the problem with printing only my current
selection, what I did was create a new action in the macro and told it to
"print out" and in the print range I chose selection, problem solved. But
now it is printing the report AND the form, not good, all I want is the
report. How do I fix this?
 
Sounds like it might work if I knew how to write code. I am not proficiant
in code, and when I went to the VB editor as instructed, the coursor was not
blinking anywhere in the lines of code.

I wrote the form in design mode and it is running off of a table, is that
the right way to do it? this is my first major database and everything seems
to be running as planned, everything autofills in the reports.

not to change the subject but how much harder would it be for me to put
checkboxes for the forms and a print button and have the print button control
it all? my boss wants this feature integrated.
 
I thought I fixed it, if I am working on a new entry on the form, I only want
to print the record with the currently selected information in the form.
nothing else, not the form or other pages just the current entry that I have
in the form that I am working on. wow this can get pretty complexed.
 
Back
Top