Auto Open, Print and Close a form

  • Thread starter Thread starter Chris Ryner
  • Start date Start date
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
 
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
 
Back
Top