471,354 Members | 1,477 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,354 software developers and data experts.

Printing Multiple Forms

I want to create a button that will print multiple forms. Each form is
a list of various orders, and there are three separate forms:

-Standard Orders
-Rush Orders
-VIP Rush Orders

Each is based off its own query.

For certain company reasons, each order type (Standard, Rush, VIP
Rush) MUST be its own separate form.

Creating a button that will print all three is easy.

What I want is a button that will only print forms if they have data
on them. For example, if there are Standard Orders and Rush Orders,
but NO VIP Orders, I only want the first two forms printed.

I'm sure there's a simple solution, but I'm self-taught and not sure
what to do!

Thanks!

Mar 19 '07 #1
5 6202

I would recommend printing reports instead. One of the report events
is OnNoData. If the query the report is based on does not contain
records, printing can be canceled. In a button click event use the
OpenReport method of DoCmd to print them you'd include one line for
each report to print...

DoCmd.OpenReport "[reportName]", acViewNormal [or acViewPreview],
[Filter], [Where]

In the OnNoData event of the report enter Cancel=True.

Mar 19 '07 #2
On Mar 19, 2:22 pm, "storrboy" <storr...@sympatico.cawrote:
I would recommend printing reports instead. One of the report events
is OnNoData. If the query the report is based on does not contain
records, printing can be canceled. In a button click event use the
OpenReport method of DoCmd to print them you'd include one line for
each report to print...

DoCmd.OpenReport "[reportName]", acViewNormal [or acViewPreview],
[Filter], [Where]

In the OnNoData event of the report enter Cancel=True.
I've been working on forms all day. I of course meant to say
reports :)

Thanks!

Mar 19 '07 #3
On Mar 19, 2:22 pm, "storrboy" <storr...@sympatico.cawrote:
I would recommend printing reports instead. One of the report events
is OnNoData. If the query the report is based on does not contain
records, printing can be canceled. In a button click event use the
OpenReport method of DoCmd to print them you'd include one line for
each report to print...

DoCmd.OpenReport "[reportName]", acViewNormal [or acViewPreview],
[Filter], [Where]

In the OnNoData event of the report enter Cancel=True.
So I've got a button that does:

DoCmd.OpenReport "Standard", acViewPreview
DoCmd.OpenReport "Rush", acViewPreview
DoCmd.OpenReport "VIP Rush", acViewPreview

Each form has the OnNoData event set to "Cancel = True"

However, the problem here is that if either of the first two reports
are empty, it cancels the operation and I get a 2501 runtime error
that says "The OpenReport action was canceled." Which makes sense,
since the program thinks the whole thing is being cancelled.

How can I get around this? thanks!

Mar 20 '07 #4
<da*******@gmail.comwrote in message
news:11*********************@n76g2000hsh.googlegro ups.com...
On Mar 19, 2:22 pm, "storrboy" <storr...@sympatico.cawrote:
>I would recommend printing reports instead. One of the report events
is OnNoData. If the query the report is based on does not contain
records, printing can be canceled. In a button click event use the
OpenReport method of DoCmd to print them you'd include one line for
each report to print...

DoCmd.OpenReport "[reportName]", acViewNormal [or acViewPreview],
[Filter], [Where]

In the OnNoData event of the report enter Cancel=True.

So I've got a button that does:

DoCmd.OpenReport "Standard", acViewPreview
DoCmd.OpenReport "Rush", acViewPreview
DoCmd.OpenReport "VIP Rush", acViewPreview

Each form has the OnNoData event set to "Cancel = True"

However, the problem here is that if either of the first two reports
are empty, it cancels the operation and I get a 2501 runtime error
that says "The OpenReport action was canceled." Which makes sense,
since the program thinks the whole thing is being cancelled.

How can I get around this? thanks!
Add an error handler to your routine and in that test the Err.Number and ignore
when it is number 2501.

On Error GoTo ErrHandler

(code)

Egress:
Exit Sub

ErrHandler:
Select Case Err.Number
Case 2501
Resume Next
Case Else
MsgBox Err.Description
Resume Egress
End Select
End Sub

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Mar 20 '07 #5
I prefer to have my no data reports print with the detail containing
text that says something to the effect that no data exists for the
report rewuested. That way you always get output that is valid.
Maybe it the auditor side of me (I did audit work for 9 years) but not
haveing a report generated on no data leaves you to ASS-U-ME that the
non-generation of the report was the correct event. Setting up an
invisible label with a solid background on top of all other data in
the detail that is toggled to visible on no data is one way to skin
the cat.

On Mar 20, 10:26 am, dancol...@gmail.com wrote:
On Mar 19, 2:22 pm, "storrboy" <storr...@sympatico.cawrote:
I would recommend printing reports instead. One of the report events
is OnNoData. If the query the report is based on does not contain
records, printing can be canceled. In a button click event use the
OpenReport method of DoCmd to print them you'd include one line for
each report to print...
DoCmd.OpenReport "[reportName]", acViewNormal [or acViewPreview],
[Filter], [Where]
In the OnNoData event of the report enter Cancel=True.

So I've got a button that does:

DoCmd.OpenReport "Standard", acViewPreview
DoCmd.OpenReport "Rush", acViewPreview
DoCmd.OpenReport "VIP Rush", acViewPreview

Each form has the OnNoData event set to "Cancel = True"

However, the problem here is that if either of the first two reports
are empty, it cancels the operation and I get a 2501 runtime error
that says "The OpenReport action was canceled." Which makes sense,
since the program thinks the whole thing is being cancelled.

How can I get around this? thanks!

Mar 20 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Jody Gelowitz | last post: by
reply views Thread by Programatix | last post: by
reply views Thread by Programatix | last post: by
9 posts views Thread by Jody Gelowitz | last post: by
4 posts views Thread by Russ | last post: by
8 posts views Thread by Rick Lederman | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.