Solved

Printout a Subform from a Form

Posted on 1998-12-11
11
227 Views
Last Modified: 2006-11-17
I have a form with a Sub Form on it.  I want the Print button on the Form to print out the Selected Record on the Sub Form.  My print button must be on the Form that has the Sub form, I dont want the Print button on the Sub Form.  So the wizards arent going to work, or can they, or do you have some sample code.

Thank you,
From Rainy Seattle
Anthony
0
Comment
Question by:SemperParatus
  • 7
  • 2
  • 2
11 Comments
 
LVL 3

Expert Comment

by:tcurtin
ID: 1970706
select the record on the subform to print then create a report to accept a parameter from the subform. Use the where clause to define the criteria:

dim strCriteria as string
strCriteria = "[field]=" & forms!formname!subformcontrol.form![field]
docmd.openreport "reportName",acviewpreview,,strcriteria

0
 

Author Comment

by:SemperParatus
ID: 1970707
I dont want to use a report.  I like it better when the user only sees forms. The user has no access to the toolbars in Access and would like to keep that way.  I would like to see the user print the form.  

What I'm looking for is a MDI Form with a form with in it.  My Main form is acting as a MDI and my Subform is the form to be printed.  The print button is on the Main form (acting as a MDI).  

Personally I would just rather use VB6.0 but the budget doesnt allow a license.

Thanks for your input.  Sorry about getting back so late, but I was really sick from the Seattle weather.  Points adjusted +10
0
 

Author Comment

by:SemperParatus
ID: 1970708
Anyone Have an Idea?  
0
 
LVL 3

Expert Comment

by:tcurtin
ID: 1970709
How about:
1. Sendkeys "^P"  (alias for control + P) for print.
2. docmd.runcommand 'select the option for printing the form'

0
 

Author Comment

by:SemperParatus
ID: 1970710
Adjusted points to 200
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

Author Comment

by:SemperParatus
ID: 1970711
Adjusted points to 300
0
 

Author Comment

by:SemperParatus
ID: 1970712
Point increased to 300 from 115!  Still need some help if you could?

0
 
LVL 7

Accepted Solution

by:
Dedushka earned 300 total points
ID: 1970713
Hi, SemperParatus!

You can't print only subform from main form, i think.
But i can propose this solution:

1. Set background color for your mainform to "white".
2. Set "Display When" property for all controls on your mainform to "Screen only", for subform this property is "Always".
3. Attach to your command button cmdPrint this procedure:

Private Sub cmdPrint_Click()
    DoCmd.PrintOut
End Sub

When your click button on mainform, the mainform and subform will be printed (logicaly), but on the paper you see only subform, because mainform is white and all controls is not printed due to "Screen Only" setting.

Cheers.
Dedushka

0
 

Author Comment

by:SemperParatus
ID: 1970714
Damn! I am learning that Access is really for the Impaired Programers (no insult intended).  Just wish my office could afford a MS License for VB 6.0, cause Access SUCKS!  Things like my problem with this SubForm.  Plus, having to SetFocus to an object first before you can do anything with it also piss me off!  AAARRRRGGGGGGGG!!!!!!!!  

I am going to show the user the Form as a Sub Form, but I will have the Print buttons print out from another form or Report,

Thanks for all your insights.
0
 
LVL 7

Expert Comment

by:Dedushka
ID: 1970715
Be not afflicted, Anthony. Access is not the best program really. I am too going  to pass on VB6. Here only I know, that in VB6 will be not less problems, than in Access. But it is another history...

Try my offer, all the same it is any way out. Certainly it is a pity, that it's impossible to make all beautifully and as it would be desirable.

May be someone else can will offer a beautiful solution.

Regards,
Dedushka

0
 

Author Comment

by:SemperParatus
ID: 1970716
Thanks for the Help.

Sorry, I forgot about this thing.

Anthony
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now