Choosing the printer and which pages to print

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to be able to choose the printer to use for my report and which pages are to be printed, at present I have created a button for printing the report but I can only print all the pages to the default printer or else I have to use print preview and make my selections from there. How can I have a button which will bring up the system printer options form and not just print direct? I think I should use the CommonDialog1.Showprinter action, but I don't know how to do this. Any suggestions
Regard
Nasos
 
Nasos:

1.) The common dialog control will not help you with choosing which pages to
print. It will only set the computer's default printer and if you are using
Access 2002 or 2003 that is not enough to change printers you also have to
change the printer object of the Application object. (See the help file).

2.) You can do a rudimentary function like that listed below to pop the
print dialog, but it has draw backs such as screen flashing and moving the
db window up in the z-order, but it may work for you.

3.) If you want a full blown solution to this issue, then take a look at our
"On the Fly Printing" classes and functions for Access that you'll find on
our web site.

HTH
--
Steve Arbaugh
ACG Soft
http://ourworld.compuserve.com/homepages/attac-cg

=========begin code=========

Public Function PrintWithDialog (strReportName as String, Optional objForm
as Object)
'Supply the report name in the first parameter and a form object (i.e. Me)
as the second
On Error resume next
Docmd.Echo False
Docmd.SelectObject acReport, strReportName, True
Docmd.RunCommand acCmdPrint
If Not objForm Is Nothing Then
Docmd.SelectObject acForm, objForm.Name
End if
Docmd.Echo True
End Function
========end code============
 
Thanks for your help, I am not a programmer and I am searching for a simple solution (if it exists), I've seen that many simple programs on the web use the printer screen just like the MS Office products. Any one any other suggestions??
Thanks
Nasos

----- SA wrote: -----

Nasos:

1.) The common dialog control will not help you with choosing which pages to
print. It will only set the computer's default printer and if you are using
Access 2002 or 2003 that is not enough to change printers you also have to
change the printer object of the Application object. (See the help file).

2.) You can do a rudimentary function like that listed below to pop the
print dialog, but it has draw backs such as screen flashing and moving the
db window up in the z-order, but it may work for you.

3.) If you want a full blown solution to this issue, then take a look at our
"On the Fly Printing" classes and functions for Access that you'll find on
our web site.

HTH
--
Steve Arbaugh
ACG Soft
http://ourworld.compuserve.com/homepages/attac-cg

=========begin code=========

Public Function PrintWithDialog (strReportName as String, Optional objForm
as Object)
'Supply the report name in the first parameter and a form object (i.e. Me)
as the second
On Error resume next
Docmd.Echo False
Docmd.SelectObject acReport, strReportName, True
Docmd.RunCommand acCmdPrint
If Not objForm Is Nothing Then
Docmd.SelectObject acForm, objForm.Name
End if
Docmd.Echo True
End Function
========end code============
 
Nasos:

The code posted in my original message is just about as simple as it gets;
there's no more simple solution. Even though you are not a programmer,
implementing that solution should not be difficult. To do so, copy and paste
the code I noted in a new general module in Access.

Then for the command button on your form, in the On Click event, use the
drop down arrow to select to use an Event Procedure. Once that is selected
a button with an elipsis (...) should appear to the right of the On Click
event. Click that button and it will open the code design module for the On
Click event of your form.

In at event, type code like this:

Private Sub cmdPrint_Click() 'Don't copy this line
On Error resume next
PrintWithDialog ("NameOfYourReportToPrint", Me)
End Sub

That's all there is to "programming"
 
PrintWithDialog ("NameOfYourReportToPrint", Me)

that's not valid VB syntax... it should be either
Call PrintWithDialog ("NameOfYourReportToPrint", Me)
or
PrintWithDialog "NameOfYourReportToPrint", Me
 
Bob:

You're correct, always seem to use the darn parenthasis, even when avoiding
the return from a function, air code mistake.

Thanks
 
Back
Top