Access:VB:Printing Form code

Posted on 2007-10-01
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 65

    Assisted Solution

    by:Jim Horn
    >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

    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

    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.
    LVL 65

    Accepted Solution

    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

    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
    <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


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
    I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
    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…
    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…

    779 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

    18 Experts available now in Live!

    Get 1:1 Help Now