Access:VB:Printing Form code

Posted on 2007-10-01
Medium Priority
Last Modified: 2013-11-28
I have multiple forms that are designed to be printed if I open them and go to FileàPrint. What is the Access VB I could use to open select forms and get them to print.  

i.e. There are 4 forms frm_student1587, frm_student2122, frm_student344, frm_student444. The user  prints 3 of them.

forms![ frm_student1587].print
forms![ frm_student2122].print
forms![ frm_student344].print
Question by:ouestque
LVL 66

Assisted Solution

by:Jim Horn
Jim Horn earned 1000 total points
ID: 19990544
>I have multiple forms that are designed to be printed
fyi forms are designed to display data via a user interface.  
Reports are designed to display data in a printed format, either file or paper.

Printing out a form will not guarantee that the exact cosmetics of the form are printed.  Reports will guarantee that.  
LVL 70

Assisted Solution

KCTS earned 200 total points
ID: 19990579
Agreed ! Forms are for on-screen display - reports are for printing. if you want to print then use a report. If you print  a form you may get a lot more than you bargained for - it tends to print ALL the records - not just the ones on screen.

You can make a report duplixtae the record on screen by uding a filyter or query that links it to the primary key of the record on screen.

Author Comment

ID: 19991364
I agree!  But with my situation I really need it to print a form. :)

Do you know the VB I would use to get it to print a form? When I go to print preview, it looks exactly like I want it, I just need the VB syntax to continue.
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

LVL 66

Accepted Solution

Jim Horn earned 1000 total points
ID: 19991929
From the form, it's DoCmd.PrintOut

From outside the form, not sure, as DoCmd.OpenForm doesn't seem to have a print to printer parameter option.

Author Comment

ID: 19992919
Theroretically then, could I write a VB sub that would allow a user to choose a number of forms i.e. 100. and follow the following procedure---> open form1--print--close form1. open form2--print--close form 2 etc... to how ever many forms chosen?
LVL 74

Assisted Solution

by:Jeffrey Coachman
Jeffrey Coachman earned 800 total points
ID: 20237482
<allow a user to choose a number of forms i.e. 100>
Print 100 forms!?!?

I think all of us are curious as to EXACTLY what  you are trying to accomplish here.
Can you explain?
There has got to be a better way!

Another thing worth mentioning, the syntax:
... is referencing the Forms "Collection". The forms collection contains only the currently OPEN forms. So your "system" might have to provide for opening 100 form and have them all open at the same time!

It might be better to us the the MSysObjects table:
  MSysObjects.Type =-32768

Good Luck!

Jeff Coachman


Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
A Case Study of using the Windows API to provide RS232 communications capability in Access without the use of Active-X controls.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

612 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