Open, print, close automatically.

  • Thread starter Thread starter Chris Ryner
  • Start date Start date
C

Chris Ryner

Hi everyone,

I have a form that when you double click a control it will open a form
and filter to the records I want to print.

every thing works manually, however I want the form to open and print all
records/forms and then close automatically.

I have tried
DoCmd.close acForm, "labels", acSaveNo
after the command that makes the print work
which is all in the form_current event.

apparently you cannot close a form from current event.

How can I make this work?
 
Not sure that the Current event is the appropriate event to be using in any
case: that event fires each time you move to another record (including
moving the first record).
 
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
 
Forms aren't intended for printing. That's what Reports are for.

Try converting your form to a report and using it instead.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Chris Ryner said:
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
Douglas J. Steele said:
Not sure that the Current event is the appropriate event to be using in
any case: that event fires each time you move to another record (including
moving the first record).
 
Back
Top