Solved

Screenprint a form in Access using VBA

Posted on 2013-01-03
11
2,352 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
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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

The System Center Operations Manager 2012, known as SCOM, is a part of the Microsoft system center product that provides the user with infrastructure monitoring and application performance monitoring. SCOM monitors:   Windows or UNIX/LinuxNetwo…
The new Microsoft OS looks great, is easier than ever to upgrade to, it is even free.  So what's the catch?  If you don't change the privacy settings, Microsoft will, in accordance with the (EULA) you clicked okay to without reading, collect all the…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

792 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