Results 1 to 11 of 11
  1. #1
    5 Star Lounger Lou Sander's Avatar
    Join Date
    Jun 2002
    Location
    Pittsburgh, PA
    Posts
    855
    Thanks
    140
    Thanked 10 Times in 9 Posts

    Printing a Form (2003)

    My frmMain is fairly complicated and includes several subforms. I would REALLY like to be able to press a Command Button and have the form print out. Possibly the best would be to print out a screen shot, but I'm open to anything. The photos do NOT need to print, but it would be nice to have them. Any suggestions?

    Screenshot attached.
    Lou Sander
    Pittsburgh, Pennsylvania
    USA

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Printing a Form (2003)

    Forms aren't really meant for printing. I'd create a report (plus subreports if necessary) that displays/prints what you want, and provide a command button that opens the report.

  3. #3
    5 Star Lounger Lou Sander's Avatar
    Join Date
    Jun 2002
    Location
    Pittsburgh, PA
    Posts
    855
    Thanks
    140
    Thanked 10 Times in 9 Posts

    Re: Printing a Form (2003)

    You're absolutely right, of course. We thought about making a report, but there's SO much special coding involved in making the form show what it shows, that making up the report might take more effort than it's worth. We're hoping to find some sort of workaround using screen shots or something.
    Lou Sander
    Pittsburgh, Pennsylvania
    USA

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Printing a Form (2003)

    Well, there is already a "Print" button on the toolbar, and you could use the Command Button Wizard to create a command button that prints the form. But I'm probably missing something here.

  5. #5
    5 Star Lounger Lou Sander's Avatar
    Join Date
    Jun 2002
    Location
    Pittsburgh, PA
    Posts
    855
    Thanks
    140
    Thanked 10 Times in 9 Posts

    Re: Printing a Form (2003)

    When I click the Print icon on the toolbar, the system goes crazy. It starts telling me it's printing pages to the printer, moving through them very quickly from 1 to over 5000 (and there are only 3800 records in my database). As the pages "print," strange things show up on the screen. Nothing ever gets to the printer, too. (Maybe something would get there if I just let the print counter go until it was finished, but I'm pretty sure that junk, if anything, would come out. )

    All in all, I'm pretty sure I'm either going to have to write a report, or find some sort of clever screen print program, or just live without my printout. But it sure would be nice to press a button and have that nice-looking form come out of my printer. ;-)

    Just having a command button to print the screen onto the printer would be GREAT!
    Lou Sander
    Pittsburgh, Pennsylvania
    USA

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Printing a Form (2003)

    There may be 3rd party screen capture applications that have an API (application program interface) or can be called using a command line, and that can send a screenshot directly to the printer, but I don't know of any. If you don't get a reply here, you might ask about it in the Software Finds and Wants forum.

  7. #7
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Printing a Form (2003)

    When you print a form, it prints all records in the current set of records on display.

    It looks like you find a record using the Listbox on the left hand side of the form.

    If you changed the operation of that listbox so instead of just finding a record, it applied a filter limiting the records displayed to just the one record, then printing the form should work OK. You may need to fiddle with the page setup.

    If you wanted to go the route of creating a report, you can make a report out of a current form by right clicking in the database window, and choosing Save As , and choosing Report as the type. You would have to repeat for any subforms, then link them all up again. This way you could remove the things you don't need to print, like the list box and the command buttons, and perhaps also include the second picture.

    You could then print it by opening the report in normal mode, with a Where condition, limiting it to just one record.
    Regards
    John



  8. #8
    5 Star Lounger Lou Sander's Avatar
    Join Date
    Jun 2002
    Location
    Pittsburgh, PA
    Posts
    855
    Thanks
    140
    Thanked 10 Times in 9 Posts

    Re: Printing a Form (2003)

    Hmmm. That might just be my solution. Thanks.
    Lou Sander
    Pittsburgh, Pennsylvania
    USA

  9. #9
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Printing a Form (2003)

    That's good to know about the right click on a form and Save As a report.

  10. #10
    5 Star Lounger Lou Sander's Avatar
    Join Date
    Jun 2002
    Location
    Pittsburgh, PA
    Posts
    855
    Thanks
    140
    Thanked 10 Times in 9 Posts

    Re: Printing a Form (2003)

    Feedback for you... I did the Save As a report, and it worked perfectly. The report it created looks EXACTLY like my form, including the photographs and the gray background (except for the two subforms at the bottom, which I don't really need). I changed the things that needed to be changed, and now I can print out something that has all the information that appears on my screen.

    I haven't yet worked on using a command button to print only the page I'm looking at, but that doesn't look like a big challenge at this point. The big challenge when I started this was duplicating all the complex formulas and code that I had used to create the entries on the form. That was conquered with a single Save As command. Truly amazing. Thank you, Woody's Lounge!

    BTW, I couldn't get the Save As by right clicking. I used the File menu and selected Save As...
    Lou Sander
    Pittsburgh, Pennsylvania
    USA

  11. #11
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Printing a Form (2003)

    I am glad that this is working.

    If you use the command button wizard you can create a button that will print a report. Unfortunately the wizard does not ask whether you want to print all records or just some, so you will have to manually add that into the code yourself. (to me it seems odd that the wizard for opening a form does this automatically, but the one for reports does not.)

    To get the exact code I need to know the field that is the Primary Key of your main table, and its data type.

    For an example below, I will assume the key is called ShipmateID and that it is a number.


    You will have a line that says : DoCmd.OpenReport stDocname, acNormal

    Immediately before that p ut these two lines

    Dim strCriteria as string
    strCriteria = "[ShipmateID]=" & me![ShipmateID]

    then at the end of the DoCmd.OpenReport stDocname, acNormal line, type a comma and intellisense will indicate that it wants a filter name. Ignore that and type another comma and it indicates it wants a where condition. At this point type strCriteria so you end up with


    DoCmd.OpenReport stDocname, acNormal,,strCriteria


    If your key field was a text field rather than a number you would need to change the lines above to:

    Dim strCriteria as string
    strCriteria = "[ShipmateID]=" & chr(34) & me![ShipmateID] & chr(34)

    and the final line does not change.
    Regards
    John



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •