Solved

Screenprint a form in Access using VBA

Posted on 2013-01-03
11
2,257 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
  • 4
  • 3
  • 2
  • +1
11 Comments
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 250 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 29

Expert Comment

by:IrogSinta
Comment Utility
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
Comment Utility
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:alevin16
Comment Utility
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
Comment Utility
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
Comment Utility
Show them this and see what they say about a report looking like it.
untitled3.jpg
0
 
LVL 84
Comment Utility
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
Comment Utility
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
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
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…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

744 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

19 Experts available now in Live!

Get 1:1 Help Now