By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,009 Members | 2,821 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,009 IT Pros & Developers. It's quick & easy.

Printing Multiple Forms

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a

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

P: n/a
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

P: n/a
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

P: n/a
<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

P: n/a
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.