Print command prints all reports in database?

N

Nancy

I have a form that is linked to a report. The form is used to entry data and
the report links to the data in the form. This report needs to be printed out
for faxing, snail mailing and emailing. I have a command button on my form
that opens the report in print preview. I then hit the print button and all
records from the form print. How do I make the print command only print the
record that is related to a particular form? I have a order id number on
both the form and the report. When I bring up Order #10, I only want to
print order #10. Now I have to go the print command and specify which page
to print. This works fine if there are only a few records but will be come a
major pain as the database expands. Any suggestions?
 
A

Al Campagna

Nancy,
Two common methods are...
Use the value from the open calling form to filter the query behind the
report.
Example... an OrderNo criteria of...
=Forms!frmMyMainForm!OrderNo
or
Use the Where argument in the OpenReport method...
DoCmd.OpenReport "YourReport",,, "OrderNo = " & OrderNo
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
N

Nancy

Just want to make sure I didn’t do something wrong. On the Print preview
button in design view I opened properties & .Event Tab, on click go to the
Visual Basic code window.

I then inserted your command between the Private Sub and the end sub. I
changed the “Your Report†to my report name. I then changed OrderNo to Order
ID as that is how it is listed in my DB. I then did Debug and compile and
saved the changes. Not sure if I was suppose to debug and compile, but once
before when someone was helping me with code, she told me to do it. I assume
it should be done with code changes. Is this correct?

When I now hit the print preview button nothing happens. What did I do
wrong? I copy and pasted the code here that I put into the Visual Basic
window.

I also tried to put this in the Event, On-load for the report and got an
error msg.

Private Sub Preview_Purchase_Order_Click()
DoCmd.OpenReport "R_PurchaseOrder", , , "OrderID = " & OrderID
End Sub
 
F

fredg

Just want to make sure I didnÿt do something wrong. On the Print preview
button in design view I opened properties & .Event Tab, on click go to the
Visual Basic code window.

I then inserted your command between the Private Sub and the end sub. I
changed the ´Your Report¡ to my report name. I then changed OrderNo to Order
ID as that is how it is listed in my DB. I then did Debug and compile and
saved the changes. Not sure if I was suppose to debug and compile, but once
before when someone was helping me with code, she told me to do it. I assume
it should be done with code changes. Is this correct?

When I now hit the print preview button nothing happens. What did I do
wrong? I copy and pasted the code here that I put into the Visual Basic
window.

I also tried to put this in the Event, On-load for the report and got an
error msg.

Private Sub Preview_Purchase_Order_Click()
DoCmd.OpenReport "R_PurchaseOrder", , , "OrderID = " & OrderID
End Sub

Nancy,
It's difficult following whet you want to do, as the words you are
using don't match what you have done.
ou claim to have a button on your form that opens the report in
Preview. There is nothing in the code you have included in that opens
the report in Preview.
You also state you also put your code in the Load event of your
report. Reports do not have a Load event.

Let me re-state what I think you wish to do.

You have a form used for data entry and you wish to Preview a report
of just the record whose ID shown on the form. Is that correct?

If so, then assuming you have a command button on your form named
"Preview_Purchase_Order" and a Field in your record named "OrderID"
that is the unique prime key field for the record, here is the code
you need to open the report in Preview.

Private Sub Preview_Purchase_Order_Click()

DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport ""R_PurchaseOrder", acViewPreview , , "OrderID = " &
Me!OrderID

End Sub

The above assumes OrderID is a Number datatype field.

However, if OrderID is a Text datatype field, then use:
DoCmd.OpenReport "R_PurchaseOrder", acViewPreview , , "OrderID = '" &
Me!OrderID & "'"

You can compile your code at anytime you make a change to it. It's
always a good idea to do so.
Now an explanation of the code above.
Access does not save new data until you move to another record, close
the form, or tell it to do so.
So....
The DoCmd.RunCommand line saves any newly entered record, otherwise
the record will not be in the table when the report is run.
The DoCmd.OpenReport line opens the report in Preview, filtered
according to what ever OrderID was displayed on the form.
If you don't explicitly tell it to open in Preview it will print out
without preview.

I hope this resolves your difficulty.
 
N

Nancy

Thank you for your help.

Let me start over. First of all, I started on this at 3am this morning and
it is now 8:30 p.m. I have zero time during the day to concentrate on this
so I got up early for a few hours of quite time so maybe I could concentrate
on what I need to do. As I may not have been clear before, let me state
again.

I created a "Navigation Form" on my database, much like a Switchboard. In my
"Navigation Form" I have my Purchase Order, Repair Order, Vendor Listing,
Order Summary, etc. When I click on one of these commands it takes me to a
form.

On my "F_PurchaseOrder", the form has a command button that opens a report.
The report is called, "R_PurchaseOrder". The primary key is "OrderID". On
my F_PurchaseOrder I have a setup tab that allows me to open related forms
from within the F_PurchaseOrder. Basically a group of command buttons
within a box. Everything works great, thanks to all that I have learned and
continue to learn on this newsgroup, except this one thing. On the
F_PurchaseOrder Setup tab, I have a command button to open the
R_PurchaseOrder Report in Print Preview mode. This works fine. But when I
hit print, it will print all records within the database, which while in the
test phase is 20 purchase order invoices.

What I want to do is to hit the print preview button, be able to verify the
info on the report for the particular purchase order and then hit print. At
this point I only want to print the one report that is related to that
particular form or record. This one report is a Purchase Order and all
reports will be the same in basic format but different in that they may be
for different vendors and with differnet parts that are being ordered. Each
invoice will be printed and filed, emailed or snail mailed to the vendor.

I followed the instructions to a tee, or so I thought. I even got up at 3am
so I could go through them again with "ZERO" intruption and I still can't
seem to get it. I tried and when I go back to the form view and click on the
button, nothing happens at all.... Not even the print preview. I went to
Allenbrowne.com and downloaded his info article and went step by step and
still can't figure out what I am doing wrong. I am about ready to give up...
I have a back-up copy of my database on my home computer and my portable zip
drive. I usually make sure I have the lasted updates on both drives and then
remove one as I go through the testing and updating to make changes to the
database. When I am comfortable with the progress I have made I update all
drives to the new changes. I am starting to feel overwhelmed though. If I
can get this one problem figured out and then get my search form up and going
I will be a "Happy Little Camper"! Thanks for any help.

Thanks for all your help.
 
F

fredg

Thank you for your help.

Let me start over. First of all, I started on this at 3am this morning and
it is now 8:30 p.m. I have zero time during the day to concentrate on this
so I got up early for a few hours of quite time so maybe I could concentrate
on what I need to do. As I may not have been clear before, let me state
again.

I created a "Navigation Form" on my database, much like a Switchboard. In my
"Navigation Form" I have my Purchase Order, Repair Order, Vendor Listing,
Order Summary, etc. When I click on one of these commands it takes me to a
form.

On my "F_PurchaseOrder", the form has a command button that opens a report.
The report is called, "R_PurchaseOrder". The primary key is "OrderID". On
my F_PurchaseOrder I have a setup tab that allows me to open related forms
from within the F_PurchaseOrder. Basically a group of command buttons
within a box. Everything works great, thanks to all that I have learned and
continue to learn on this newsgroup, except this one thing. On the
F_PurchaseOrder Setup tab, I have a command button to open the
R_PurchaseOrder Report in Print Preview mode. This works fine. But when I
hit print, it will print all records within the database, which while in the
test phase is 20 purchase order invoices.

What I want to do is to hit the print preview button, be able to verify the
info on the report for the particular purchase order and then hit print. At
this point I only want to print the one report that is related to that
particular form or record. This one report is a Purchase Order and all
reports will be the same in basic format but different in that they may be
for different vendors and with differnet parts that are being ordered. Each
invoice will be printed and filed, emailed or snail mailed to the vendor.

I followed the instructions to a tee, or so I thought. I even got up at 3am
so I could go through them again with "ZERO" intruption and I still can't
seem to get it. I tried and when I go back to the form view and click on the
button, nothing happens at all.... Not even the print preview. I went to
Allenbrowne.com and downloaded his info article and went step by step and
still can't figure out what I am doing wrong. I am about ready to give up...
I have a back-up copy of my database on my home computer and my portable zip
drive. I usually make sure I have the lasted updates on both drives and then
remove one as I go through the testing and updating to make changes to the
database. When I am comfortable with the progress I have made I update all
drives to the new changes. I am starting to feel overwhelmed though. If I
can get this one problem figured out and then get my search form up and going
I will be a "Happy Little Camper"! Thanks for any help.

Thanks for all your help.

Why have a second command button to print the report.
Can't you have the user simply click on the Print tool button?
That should print the filtered report.

If not, and you want 2 command buttons, then let's try it this way.
From a command button on your form, to Preview the filtered report
ONLY:

Private Sub Preview_Report_Click()

' Save any newly entered data
DoCmd.RunCommand acCmdSaveRecord
' Preview the report filtered on the [OrderID] field.
DoCmd.OpenReport "R_PurchaseOrder", acViewPreview , , "OrderID = " &
Me!OrderID

End Sub

From a second command button on your form to print the already open
previewed report:

Private Sub Print_Previewed_Report_Click()

' If the report is not open in preview then do nothing
If Not CurrentProject.AllReports("R_PurchaseOrder").IsLoaded Then
MsgBox "The report must be open in preview before you print it."
Exit Sub
Else
' The report is open so select the previewed filtered report
DoCmd.SelectObject acReport, "R_PurchaseOrder", False
' Print out 1 copy of the report
DoCmd.PrintOut acPrintAll, , , ,1
End If

End Sub

This should be all you need do.
Change the command button names to whatever your actual button names
are. The above assumes you have Access 2000 or newer.
 
A

Al Campagna

Nancy,
I just wanted to warn you that in my suggested code, on a previous post,
I made a typo error.

DoCmd.OpenReport "YourReport",,, "OrderNo = " & OrderNo (Wrong)
should be...
DoCmd.OpenReport "YourReport",, "OrderNo = " & OrderNo
only two commas ^

I'll leave you to continue to work on this problem Fred G.

But... whenever you try code, and it doesn't work... we need to see the
exact code you used (cut & paste it directly into your post, for accuracy)
Also, stick with the code Fred and I suggested. It's OK to try things on
your own, but always be sure to put your code back to exactly what
Fred suggested... before continuing problem determination.
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
N

Nancy

Thanks for your responses.

Here is what I copied & pasted, after I removed the instructions. The
DoCmd.Open Report line showed up in red and when I hit the debug it
highlighted the line and told me I had a compile error. What did I do wrong
now? As for your last post. I want to hit the preview report button on the
form, have the current report come up to view and then print. I have no
problem printing from the print command under the file menu. The problem I
have is trying to get just the current report open without all the others. I
really don't need a second command button to print. Just preview the report
for accuracy and then print from the file/print command and have it "just
print the current report'.

If I were the only one that would be using it, I would just hit the print
command and make sure I click current window for printing and save myself the
current headache. LOL! But others will be using it and I want to make sure
when they hit print, they print only the current record and not 9000 others.
Thank you for being patient with me. Currently I have a macro to open the
report but like I said I get all the reports and when I hit the print they
all print out.

Thank you for being patient with me.

Private Sub Preview_Report_Click()

DoCmd.RunCommand acCmdSaveRecord

DoCmd.OpenReport "R_PurchaseOrder", acViewPreview , , "OrderID = " &
Me!OrderID

End Sub
 
A

Al Campagna

Nancy,
Is the OpenReport code all on one line? It should be...
Emails in newsgroups wrap any text longer than 80 characters, so you may
have thought the code went on two lines.

What data type is OrderID... Text or Numeric??

If Text... (I'll put spaces between the quotes for clarity... there
should be no spaces in the real code)
DoCmd.OpenReport "R_PurchaseOrder", acViewPreview , , "OrderID = ' " &
Me.OrderID & " ' "
(Notice the Me.OrderID, instead of Me!OrderID. Not sure that's a
problem, but try the period.)

If Numeric...
DoCmd.OpenReport "R_PurchaseOrder", acViewPreview , , "OrderID = " & OrderID

Try the above. If we still have problems, could you zip and email me
your file/s via my website below?
Or... just the tables/forms/reports we need to duplicate the problem.
No Charge... strictly confidential.
Use the word "newsgroup" in your subject, and tell what version you are
using, and the name of the form and report involved.
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
N

Nancy

I tried to send you a copy of the database and it was returned undeliverable.
I went back and looked at my tables and may have spotted an error.

The Order Table is my main table for purchase orders has the following:

Order ID-Auto number and Primary key


The Order Detail Table is my details for the subform and it has the following:

OrderDetailID- Auto number and Primary Key
OrderID-Number

The Link Master Field is: OrderID
The Link Child Field is: OrderID


The relationship is:

Orders Table: OrderID: One
OrderDetails Table: OrderID: Many

Could my problem be with the OrderID for the two tables?
 
A

Al Campagna

Nancy,
Did you Compact and Zip the database? What was it's size? (must be 10MB
or less)
Did you use my Contact button on my website for your email?
Did the email subject contain the word "newsgroup"
In the email body, indicate your Acccess version, and the form/report
involved.

The reason why I ask, is that what you indicated in this latest post is
correct.
Please try to resend... we're missing something here... that I could
probably find quickly... if I could see your form.

But... let's try something different.
In your subform, on the OrderID key field (Enabled but Locked), use it's
DoubleClick event to run this code...

Private Sub OrderID_DblClick(Cancel As Integer)
DoCmd.OpenReport "R_PurchaseOrder", acViewPreview , , "OrderID = " &
OrderID
End Sub

This should open the report, filtered by the OrderID
Hang in there... and, if this dowsn't work... I really need to see that
mdb.
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
N

Nancy

I tried once again to send you the database at the contact spot. It was
again returned to me. I zipped and sent it to you and it was way smaller
then 10

In your subform, on the OrderID key field (Enabled but Locked), use it's
DoubleClick event to run this code...

I don't understand this procedure. Can you explain it to me a little more
basically. I will try again to email the file to you.

Thanks for your patience.
BTW, I am using Access 2007
 
A

Al Campagna

Nancy,
Got the file. Fixed and sent back to you.
For others reading this thread... the OpenReport Where argument
should have been looking for [Orders_OrderID] in the report query... not
[OrderID]
Query criteria...
[Orders_OrderID] = [Forms]![F_PurchaseOrder]![OrderID]
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
N

Nancy

Thank you so much for all of your help. I have not had the opportunity to
look at it yet, but will as soon as I get home from work. I was going to
forward to my work email, but my laptop battery died before the send was
completed. LOL.

Al and company, thank you again for your help and patience with me. This
newsgroup is such a great place to learn.

Al Campagna said:
Nancy,
Got the file. Fixed and sent back to you.
For others reading this thread... the OpenReport Where argument
should have been looking for [Orders_OrderID] in the report query... not
[OrderID]
Query criteria...
[Orders_OrderID] = [Forms]![F_PurchaseOrder]![OrderID]
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."

Nancy said:
I tried once again to send you the database at the contact spot. It was
again returned to me. I zipped and sent it to you and it was way smaller
then 10

In your subform, on the OrderID key field (Enabled but Locked), use it's
DoubleClick event to run this code...

I don't understand this procedure. Can you explain it to me a little more
basically. I will try again to email the file to you.

Thanks for your patience.
BTW, I am using Access 2007
 
A

Al Campagna

Nancy,
No problem... you're welcome.
Let us know how you make out, once you've had a chance to test...
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."

Nancy said:
Thank you so much for all of your help. I have not had the opportunity to
look at it yet, but will as soon as I get home from work. I was going to
forward to my work email, but my laptop battery died before the send was
completed. LOL.

Al and company, thank you again for your help and patience with me. This
newsgroup is such a great place to learn.

Al Campagna said:
Nancy,
Got the file. Fixed and sent back to you.
For others reading this thread... the OpenReport Where argument
should have been looking for [Orders_OrderID] in the report query... not
[OrderID]
Query criteria...
[Orders_OrderID] = [Forms]![F_PurchaseOrder]![OrderID]
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your
life."

Nancy said:
I tried once again to send you the database at the contact spot. It was
again returned to me. I zipped and sent it to you and it was way
smaller
then 10

In your subform, on the OrderID key field (Enabled but Locked), use
it's
DoubleClick event to run this code...

I don't understand this procedure. Can you explain it to me a little
more
basically. I will try again to email the file to you.

Thanks for your patience.
BTW, I am using Access 2007
:

Nancy,
Did you Compact and Zip the database? What was it's size? (must
be
10MB
or less)
Did you use my Contact button on my website for your email?
Did the email subject contain the word "newsgroup"
In the email body, indicate your Acccess version, and the
form/report
involved.

The reason why I ask, is that what you indicated in this latest
post
is
correct.
Please try to resend... we're missing something here... that I
could
probably find quickly... if I could see your form.

But... let's try something different.
In your subform, on the OrderID key field (Enabled but Locked),
use
it's
DoubleClick event to run this code...

Private Sub OrderID_DblClick(Cancel As Integer)
DoCmd.OpenReport "R_PurchaseOrder", acViewPreview , , "OrderID = "
&
OrderID
End Sub

This should open the report, filtered by the OrderID
Hang in there... and, if this dowsn't work... I really need to
see
that
mdb.
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your
life."


I tried to send you a copy of the database and it was returned
undeliverable.
I went back and looked at my tables and may have spotted an error.

The Order Table is my main table for purchase orders has the
following:

Order ID-Auto number and Primary key


The Order Detail Table is my details for the subform and it has the
following:

OrderDetailID- Auto number and Primary Key
OrderID-Number

The Link Master Field is: OrderID
The Link Child Field is: OrderID


The relationship is:

Orders Table: OrderID: One
OrderDetails Table: OrderID: Many

Could my problem be with the OrderID for the two tables?


:

Nancy,
Is the OpenReport code all on one line? It should be...
Emails in newsgroups wrap any text longer than 80 characters,
so
you
may
have thought the code went on two lines.

What data type is OrderID... Text or Numeric??

If Text... (I'll put spaces between the quotes for clarity...
there
should be no spaces in the real code)
DoCmd.OpenReport "R_PurchaseOrder", acViewPreview , , "OrderID = '
" &
Me.OrderID & " ' "
(Notice the Me.OrderID, instead of Me!OrderID. Not sure that's
a
problem, but try the period.)

If Numeric...
DoCmd.OpenReport "R_PurchaseOrder", acViewPreview , , "OrderID = "
&
OrderID

Try the above. If we still have problems, could you zip and
email
me
your file/s via my website below?
Or... just the tables/forms/reports we need to duplicate the
problem.
No Charge... strictly confidential.
Use the word "newsgroup" in your subject, and tell what version
you
are
using, and the name of the form and report involved.
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in
your
life."


Thanks for your responses.

Here is what I copied & pasted, after I removed the instructions.
The
DoCmd.Open Report line showed up in red and when I hit the debug
it
highlighted the line and told me I had a compile error. What did
I
do
wrong
now? As for your last post. I want to hit the preview report
button
on
the
form, have the current report come up to view and then print. I
have
no
problem printing from the print command under the file menu. The
problem
I
have is trying to get just the current report open without all
the
others.
I
really don't need a second command button to print. Just preview
the
report
for accuracy and then print from the file/print command and have
it
"just
print the current report'.

If I were the only one that would be using it, I would just hit
the
print
command and make sure I click current window for printing and
save
myself
the
current headache. LOL! But others will be using it and I want
to
make
sure
when they hit print, they print only the current record and not
9000
others.
Thank you for being patient with me. Currently I have a macro to
open
the
report but like I said I get all the reports and when I hit the
print
they
all print out.

Thank you for being patient with me.

Private Sub Preview_Report_Click()

DoCmd.RunCommand acCmdSaveRecord

DoCmd.OpenReport "R_PurchaseOrder", acViewPreview , , "OrderID =
" &
Me!OrderID

End Sub
 
N

Nancy

Al, thank you again. It does exactly what I wanted it to do. I opened up
the macro to see what you did and now I understand it. I was very confused
before and probably frustrated beyond confusion. Now I understand. I took
that concept and used it to do the same with the RepairOrder Report.

Thanks a million,

Nancy

Al Campagna said:
Nancy,
No problem... you're welcome.
Let us know how you make out, once you've had a chance to test...
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."

Nancy said:
Thank you so much for all of your help. I have not had the opportunity to
look at it yet, but will as soon as I get home from work. I was going to
forward to my work email, but my laptop battery died before the send was
completed. LOL.

Al and company, thank you again for your help and patience with me. This
newsgroup is such a great place to learn.

Al Campagna said:
Nancy,
Got the file. Fixed and sent back to you.
For others reading this thread... the OpenReport Where argument
should have been looking for [Orders_OrderID] in the report query... not
[OrderID]
Query criteria...
[Orders_OrderID] = [Forms]![F_PurchaseOrder]![OrderID]
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your
life."

I tried once again to send you the database at the contact spot. It was
again returned to me. I zipped and sent it to you and it was way
smaller
then 10

In your subform, on the OrderID key field (Enabled but Locked), use
it's
DoubleClick event to run this code...

I don't understand this procedure. Can you explain it to me a little
more
basically. I will try again to email the file to you.

Thanks for your patience.
BTW, I am using Access 2007
:

Nancy,
Did you Compact and Zip the database? What was it's size? (must
be
10MB
or less)
Did you use my Contact button on my website for your email?
Did the email subject contain the word "newsgroup"
In the email body, indicate your Acccess version, and the
form/report
involved.

The reason why I ask, is that what you indicated in this latest
post
is
correct.
Please try to resend... we're missing something here... that I
could
probably find quickly... if I could see your form.

But... let's try something different.
In your subform, on the OrderID key field (Enabled but Locked),
use
it's
DoubleClick event to run this code...

Private Sub OrderID_DblClick(Cancel As Integer)
DoCmd.OpenReport "R_PurchaseOrder", acViewPreview , , "OrderID = "
&
OrderID
End Sub

This should open the report, filtered by the OrderID
Hang in there... and, if this dowsn't work... I really need to
see
that
mdb.
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your
life."


I tried to send you a copy of the database and it was returned
undeliverable.
I went back and looked at my tables and may have spotted an error.

The Order Table is my main table for purchase orders has the
following:

Order ID-Auto number and Primary key


The Order Detail Table is my details for the subform and it has the
following:

OrderDetailID- Auto number and Primary Key
OrderID-Number

The Link Master Field is: OrderID
The Link Child Field is: OrderID


The relationship is:

Orders Table: OrderID: One
OrderDetails Table: OrderID: Many

Could my problem be with the OrderID for the two tables?


:

Nancy,
Is the OpenReport code all on one line? It should be...
Emails in newsgroups wrap any text longer than 80 characters,
so
you
may
have thought the code went on two lines.

What data type is OrderID... Text or Numeric??

If Text... (I'll put spaces between the quotes for clarity...
there
should be no spaces in the real code)
DoCmd.OpenReport "R_PurchaseOrder", acViewPreview , , "OrderID = '
" &
Me.OrderID & " ' "
(Notice the Me.OrderID, instead of Me!OrderID. Not sure that's
a
problem, but try the period.)

If Numeric...
DoCmd.OpenReport "R_PurchaseOrder", acViewPreview , , "OrderID = "
&
OrderID

Try the above. If we still have problems, could you zip and
email
me
your file/s via my website below?
Or... just the tables/forms/reports we need to duplicate the
problem.
No Charge... strictly confidential.
Use the word "newsgroup" in your subject, and tell what version
you
are
using, and the name of the form and report involved.
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in
your
life."


Thanks for your responses.

Here is what I copied & pasted, after I removed the instructions.
The
DoCmd.Open Report line showed up in red and when I hit the debug
it
highlighted the line and told me I had a compile error. What did
I
do
wrong
now? As for your last post. I want to hit the preview report
button
on
the
form, have the current report come up to view and then print. I
have
no
problem printing from the print command under the file menu. The
problem
I
have is trying to get just the current report open without all
the
others.
I
really don't need a second command button to print. Just preview
the
report
for accuracy and then print from the file/print command and have
it
"just
print the current report'.

If I were the only one that would be using it, I would just hit
the
print
command and make sure I click current window for printing and
save
myself
the
current headache. LOL! But others will be using it and I want
to
make
sure
when they hit print, they print only the current record and not
9000
others.
Thank you for being patient with me. Currently I have a macro to
open
the
report but like I said I get all the reports and when I hit the
print
they
all print out.

Thank you for being patient with me.

Private Sub Preview_Report_Click()

DoCmd.RunCommand acCmdSaveRecord

DoCmd.OpenReport "R_PurchaseOrder", acViewPreview , , "OrderID =
" &
Me!OrderID

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top