Auto Open, Print and Close a form

C

Chris Ryner

What event should I be using....
when I dbl click on a control on form1 the code is

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "label"

stLinkCriteria = "[PO_NUMBER]=" & "'" & Me![PO_NUMBER] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

This opens the "label" form and filters it to only the records I want to
print out. I technically don't need to display this form just print all of
its filtered records then close automatically.

right now in the form current of "label" i have the following

Dim stDocName As String
Dim MyForm As Form

stDocName = "label"
Set MyForm = Screen.ActiveForm
DoCmd.SelectObject acForm, stDocName, True
DoCmd.PrintOut

How can I print all the filtered records on the label form by clicking on
the PO number field on form1 with out showing the label form or immediately
closing after printing.

I have tried various combinations of docmd.close and close and others.
Where am I going wrong.

Thanks
Chris
 
A

Allen Browne

Essentially, use OpenReport instead of OpenForm:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Report1"
stLinkCriteria = "[PO_NUMBER]=" & "'" & Me![PO_NUMBER] & "'"
DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria
 

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