printing subforms (1 Viewer)

reel knotty

Registered User.
Local time
Today, 10:37
Joined
Jun 5, 2002
Messages
71
Ok guys Heres the skinny...
I am working on a form with 2 subforms. The form is to be used as a confirmation print out. Problem is when I try to print the form it only prints (or displays in preview) the parent form and no information of the child forms.

As always any input is greatly appreciated!

Nate
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 05:37
Joined
Feb 19, 2002
Messages
29,448
Forms are not optimized for printing. And due to the nature of subforms, Access cannot print them.

Create a report with subreports. In your print button, use the OpenReport Method. Use the where argument to supply the key of the main report record.
 

wizcow

Registered User.
Local time
Today, 03:37
Joined
Sep 22, 2001
Messages
236
Nate

The printing of forms is troublesome business.

Your best bet is to make a Report.
Have your print button open the Report and have the Report's control source be tied to a query that looks up the information on your form.

HTH
Tom
 

reel knotty

Registered User.
Local time
Today, 10:37
Joined
Jun 5, 2002
Messages
71
Thanks Guys! I ended up creating a report from the form. I know it is not the normal way but some of the info on the subforms I wanted to print is not related after it is entered.


Thanks again for the tip!!
 

Timbo99

New member
Local time
Today, 10:37
Joined
Mar 30, 2003
Messages
7
This Works

I use a command button on the subform (printer icon).. set it's properties to visible 'screen only'. now paste this code into the buttons 'on click'



Dim stDocName As String
Dim MyForm As Form

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



Works for me!
 

Mr. Southern

Registered User.
Local time
Today, 04:37
Joined
Aug 29, 2019
Messages
90
Re: This Works

I use a command button on the subform (printer icon).. set it's properties to visible 'screen only'. now paste this code into the buttons 'on click'



Dim stDocName As String
Dim MyForm As Form

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



Works for me!


I know this thread is really old but what would you need to change if you wanted to print it in landscape view?
 

Mark_

Longboard on the internet
Local time
Today, 02:37
Joined
Sep 12, 2017
Messages
2,111
Open the report in design view.
Click on the "Page Setup"
In "Page Layout" select "Landscape"
 

Mark_

Longboard on the internet
Local time
Today, 02:37
Joined
Sep 12, 2017
Messages
2,111
I'd create a report to do what you need as they are actually for printing, but if that isn't an option, check out THIS THREAD and see if it answers your question.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom