rwrede said:
I added a print button to my form... I added this code (replaced) to the
form button in VB,
Dim strDocName As String
Dim strWhere As String
strDocName = "Order Form"
strWhere = "[OrderID] = " & Me.[OrderID]
DoCmd.OpenReport strDocName, acViewPreview, , strWhere
When I click the print button on my form I get an inquiry asking "Which
OrderID" I put in the desired number and when I click "Ok" I get the report
in it's print preview mode... (it doesn't print on it's own and if I print
it manually it prints all the pages of the report, not just the one in view)
You should not be getting a prompt for the OrderID. I don't
know where it's coming from, but maybe adding that field to
the report's record source query will deal with it???
To include the field in the report's query, open the query
in design view. You should see the base table's field list,
then drag the OrderID field down to the query's field list.
Close and save the query.
Now open the report in design view, you should now see the
OrderID field in the report's field list (View menu - Field
List). Drag the field to somewhere on the report to create
a text box bound to the field. If you do not want to
display the OrderID value in the report, set the text box's
Visible property to No.
Once all that is working, if you open the report from the
database window you should see **all** the orders. But,
when you use the report button on the form, you should,
without any prompt, see only the order that was selected on
the form. Printing that report while previewing it should
just be a matter of clicking on the Print tool bar item. If
you do not want to preview the order and send it directly to
the printer, you can create another button on the form using
the same code except for using acViewNormal instead of
acViewPreview.