Printing an unopened form

P

Pele

I used the command button wizard to create a command button for printing a
form. The intention is for the user to click the command button on one form
(frm_Update Rate Table_MAIN) and that should print off the subform (a
continous form called Frm_Update Rate Table).

The problem is, the print button seems to be printing the Main form (showing
all the other buttons on the Main form) but I only want it to print the
continous subform (lines of records).

Belwo is the code the wizard wrote...can anybody help.

Pele

Private Sub Cmd_print_Update_rate_Click()
On Error GoTo Err_Cmd_print_Update_rate_Click

Dim stDocName As String
Dim MyForm As Form

stDocName = "Frm_Update Rate Table"
Set MyForm = Screen.ActiveForm
DoCmd.SelectObject acForm, stDocName, True
DoCmd.PrintOut
DoCmd.SelectObject acForm, MyForm.Name, False

Exit_Cmd_print_Update_rate_Click:
Exit Sub

Err_Cmd_print_Update_rate_Click:
MsgBox Err.Description
Resume Exit_Cmd_print_Update_rate_Click

End Sub
 
B

Brian

If what you want is the data on the subform, consider creating a report that
displays the same information (i.e. filtered to the records that would appear
on ths subform. You will have far more control over the format of the
printout. Then, you simply open the report. The report's RecordSource should
be virtually the same as that of the subform, with the addition of the filter.

DoCmd.OpenReport "MyReport", acViewNormal 'use acViewPreview to preview
instead of print.
 

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