473,396 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Selecting a printer when printing a report using a command button

12
I’m trying to set up the printer button on my form, I want it to allow the user to select a printer when you try to print the report. I know that the code for this is
Expand|Select|Wrap|Line Numbers
  1. “DoCmd.RunCommand acCmdPrint”
However, I don’t know where to fit it into the current code that automatically prints out that report:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Print_Click()
  2. On Error GoTo Err_Print_Click
  3.  
  4.     Dim stDocName As String
  5.  
  6.     stDocName = "Result_Set"
  7.     DoCmd.OpenReport stDocName, acNormal
  8.  
  9. Exit_Print_Click:
  10.     Exit Sub
  11.  
  12. Err_Print_Click:
  13.     MsgBox Err.Description
  14.     Resume Exit_Print_Click
  15.  
  16. End Sub 
Thanks

Sunny
Feb 21 '11 #1
1 4077
Lysander
344 Expert 100+
Okay, I have not done this myself, but I thought it should be possible. Normally, a report is printed to the 'default' printer or you can open the report in preview mode, and the user can select the printer when they print the report.

If you want the user to select a printer first, then obviously you will need a drop-down box listing all the possible printers and then use this property of the report that I have just come across

(From the Access Help Files)

PrtDevNames Property
You can use the PrtDevNames property to set or return information about the printer selected in the Print dialog box for a form or report. Read/write Variant.

It looks very complicated, the first part of the help file entry states

"Remarks
It is strongly recommended that you consult the Win32 Software Development Kit for complete documentation on the PrtDevMode, PrtDevNames, and PrtMip properties.

The PrtDevNames property is a variable-length structure that mirrors the DEVNAMES structure defined in the Win32 Software Development Kit.

Microsoft Access sets the PrtDevNames property when you make selections in the Printer section of the Print dialog box. You can also set the property by using Visual Basic.

Microsoft Access uses the DEVNAMES structure to initialize the Print dialog box. When the user chooses OK to close the dialog box, information about the selected printer is returned by the PrtDevNames property.

©2003 Microsoft Corporation"

I'm not sure why you want to do this, as the user can select and/or change the printer when they right click on the report and select print?
Feb 21 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Xiphias | last post by:
Hi, Im trying to change the color of a text box on a report that im printing from a form. On the form I got a check box that has to tricker the color of that textbox on the printed report....
4
by: bshort1023 | last post by:
Hello, If my report is only 1 page I would like the page footer to print and not the report footer. If the report is more than 1 page I would like the report footer to print and I don't want...
9
by: rdade22 | last post by:
Hi, I'm new so try to bare with me. I'm using access 2000 and I created a database where the user is prompted to click on a command button and the info that was put on the form is sent to a table....
5
by: dgrabuloff | last post by:
i am inputting records using a form. how do i put a command button on the form that will copy the record i just input----sometimes i have the same record that needs to be put in 3 or 4 times and i...
5
by: martin DH | last post by:
Hello, I am using MS Access 2002-2003. I added a "Print Record" command button to a form in my database. Is there a way (via VBA or anything else) to open a print preview screen when the command...
4
by: sirimanna | last post by:
hi, Is any one can help me to open files in my computer(for an example: some word document)using command button... i want to open file's using my vb programme..but i can't do it...can any one...
2
by: tejavenkat | last post by:
Hi, I have one scenario i.e Download as csv is there it is a command button when we click on this the save dialog box should be open,Am using javascript how can we do this by using by javascrpt...
0
by: mesadobes | last post by:
I am very new to visual basic. Actually, I have no clue what I'm doing! But I know what I want to do. I am trying to learn as I go... How do I create a command button that when clicked will...
6
by: TAZdba | last post by:
Hi All, I have an Access97 frontend on a SQL Server 2005 back end database. Reading your forums, I discovered how to generate a dropdown list of available printers. I can also store the user's...
1
by: 85ssp | last post by:
I am working on debugging a multithreaded network application. I have two forms. One of which is my testing form, the other is the actual user form. I need to be able to load only my testing form...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.