Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Screenprint a form in Access using VBA

Posted on 2013-01-03
11
Medium Priority
?
2,576 Views
Last Modified: 2013-01-04
Hey Everyone,

This does not seem like a big deal but for some reason I cannot figure it out.  I have a very busy screen (lots of fields and data) and I want to have a button that will do a printscreen.  Right now I have the user do an ALt+PrintScreen, paste the result into Paint, and then print from there.  

Is there an easier way to do it via VBA?  I have tried this code:

DoCmd.SelectObject acForm, Screen.ActiveForm.Name, False
 DoCmd.PrintOut

and it crashes Access.  I have attached a jpg of the screen
screen.jpg
0
Comment
Question by:alevin16
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +1
11 Comments
 
LVL 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 1000 total points
ID: 38742127
This MSFT article explains how to do it:

http://support.microsoft.com/?kbid=240653

that's for Visual Basic, but it should work for VBA also.
0
 
LVL 29

Assisted Solution

by:IrogSinta
IrogSinta earned 1000 total points
ID: 38742506
Well, CTRL-P will bring up the print dialog box and you can print directly from there instead of pasting your screenshot into another program; however, I don't recommend printing straight from a form, especially one such as yours since you end up wasting a lot of ink/toner due to the printing of unnecessary items such as the background color and form buttons.  It's really best to create a report from the form and use that for printing.
0
 

Author Comment

by:alevin16
ID: 38742575
I tried the ctrl+p but it did what happened before, crashed access.  I completely agree with you that printing the form is a waste of toner but they are very set in their ways and they want to print the entire form.  Believe me I tried selling them on creating a report but they did not want to hear it.
0
Technology Partners: 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!

 
LVL 29

Expert Comment

by:IrogSinta
ID: 38742602
The whole idea is to give them a report that looks like the form but without the background color and the buttons cluttering up their report.  Why would they be opposed to this if you give them a button on the form that prints exactly what they see without the clutter?
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 38742624
You can use LSM's code to copy the screen to the clipboard...
But if your ultimate goal is to also paste the image into paint, ...then print it out (meaning all three of these steps to be done via VBA automation), ...then this is another story.

You can also do as IrogSinta suggests...
(Print the Form, or create a Report for printing)


So it seems that your ultimate goal here is unclear.
Do you actually want just a screenshot of the form (perhaps as a training tool?)
...Or do you just need a printout of the form to see the data?

JeffCoachman
0
 

Author Comment

by:alevin16
ID: 38742631
I wish I knew.  Maybe they cannot picture it.  I may have to go forward and create it and show it to them, but I don't feel like wasting all that time just to have them say no.
0
 

Author Comment

by:alevin16
ID: 38742642
Hello JeffCoachman,

WHen they explain it to me it sounds like they just need the data (I have no clue why anyone would need to see a button etc) but when I said I would create a report that looked like the screen they freaked out and said that they cannot have it that way for their files.  They need to have a printout of the screen EXACTLY as it shows on the screen with the buttons, data and everything.  I am thinking I might have to use a macro recorder and record the steps for a screen print and just do that (not incorporate it into the access program)
0
 
LVL 29

Expert Comment

by:IrogSinta
ID: 38742690
Show them this and see what they say about a report looking like it.
untitled3.jpg
0
 
LVL 85
ID: 38743191
The code at the sample I linked does just that - it prints the screen. What would be the point of a macro recorder?
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 38744092
alevin16,

Ok, thanks for the clarification...
I'll let you continue on with the other two experts to avoid confusion...


JeffCoachman
0
 

Author Comment

by:alevin16
ID: 38744612
Hello LSMConsulting - I tried the code but the printing part of the code did not work.  It claimed it did not understand this line:

 Printer.PaintPicture Picture1.Picture, 0, 0

I think I am going to have to just force them to accept a report that looks like the screen without the buttons.
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

715 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