Solved

Screenprint a form in Access using VBA

Posted on 2013-01-03
11
2,485 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 250 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 250 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
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

617 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