Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VB 6.0 Report, User Printer Selection

Posted on 2004-10-28
10
Medium Priority
?
165 Views
Last Modified: 2010-05-02
I have an APP with several VB 6.0 reports, one of which is called 'rptMainInfo'.  I currently have logic that allows the user to select whether they want to view the report on the screen or send it to the printer.  Based on thier response the following code accomplishes that:

With rptMainInfo
  Set .DataSource = rsMainInfo
  .DataMember = rsMainInfo.DataMember
  DoEvents
    If PrintEm = True Then
        .PrintReport
    Else
        .Show vbModal
    End If

End With

If the print option is selected, the report is sent directly to the default printer without giving the user any chance to direct it elsewhere.  The user now wants the ability to decide which printer to send the hard copy output.  Showing them the standard windows printer selection box would be ideal if possible.  If not, are there other options?  Any ideas on how to accomplish this within the program flow?

I also have some output being generated by the Printform command.  Is there anyway to allow them to select where they want to direct that output?
0
Comment
Question by:mlcktmguy
[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
10 Comments
 
LVL 48

Expert Comment

by:Mikal613
ID: 12437498
you can add your own combo Box  and do this

Private Sub LoadPrinters()

Dim P as Printer

 For Each P In Printers
        CMB.Additem  P.DeviceName & " on " & P.Port =
  Next

End sub

0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 12437499
Here is an example that uses a combobox:

Private Sub Form_Load()
LoadPrinters
End Sub

Private Sub Combo1_Click()
Set Printer = Printers(Combo1.ListIndex)
End Sub

Private Sub LoadPrinters()
Dim pr As Printer

For Each pr In Printers
   Combo1.AddItem pr.DeviceName
Next pr
Combo1.Text = Printer.DeviceName

End Sub
0
 
LVL 48

Expert Comment

by:Mikal613
ID: 12437510
When you print  you then Set the printer to what he slelected


dim P as printer
For Each P In Printers
        If P.DeviceName & " on " & P.Port = cboPrinters.Text Then
            Set Printer = P
            Exit For
        End If
    Next
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 48

Accepted Solution

by:
Mikal613 earned 1000 total points
ID: 12437531
else

add a Common Dialog

and do showprinter
0
 
LVL 14

Expert Comment

by:Shiju Sasidharan
ID: 12437616
hi
try this
'----------------------------------------
With rptMainInfo
  Set .DataSource = rsMainInfo
  .DataMember = rsMainInfo.DataMember
  DoEvents
    If PrintEm = True Then
'>> Change made here..

        .PrintReport True
    Else
        .Show vbModal
    End If

End With
'-----------------------------

;-)
Shiju

0
 
LVL 1

Author Comment

by:mlcktmguy
ID: 12440440
when I put in the command ShowPrinter I get a compile error.  The ShowPrinter command is highlighted and the message is:

Sub or Function Not Defined

0
 
LVL 48

Expert Comment

by:Mikal613
ID: 12444623
Did you add a Commn Dialog ??
0
 
LVL 48

Expert Comment

by:Mikal613
ID: 12444642
CommonDialog Control
           

The CommonDialog control provides a standard set of dialog boxes for operations such as opening and saving files, setting print options, and selecting colors and fonts. The control also has the ability to display help by running the Windows Help engine.

Syntax

CommonDialog

Remarks

The CommonDialog control provides an interface between Visual Basic and the routines in the Microsoft Windows dynamic-link library Commdlg.dll. To create a dialog box using this control, Commdlg.dll must be in your Microsoft Windows SYSTEM directory.

You use the CommonDialog control in your application by adding it to a form and setting its properties. The dialog displayed by the control is determined by the methods of the control. Atrun time, a dialog box is displayed or the help engine is executed, when the appropriate method is invoked; atdesign time, the CommonDialog control is displayed as an icon on a form. This icon can't be sized.

The CommonDialog control can display the following dialogs using the specified method.

Method Dialog Displayed
ShowOpen Show Open Dialog Box
ShowSave Show Save As Dialog Box
ShowColor Show Color Dialog Box
ShowFont Show Font Dialog Box
ShowPrinter Show Print or Print Options Dialog Box
ShowHelp Invokes the Windows Help Engine


0
 
LVL 1

Author Comment

by:mlcktmguy
ID: 12444683
Yes, that worked better than the combo box approach.  I'm not sure why?
When I used the combo box I had 'stops' throughout the code to make sure that it was setting the printer properly based on what was selected.  It was, but when I printed the report it still went to the default printer.  I decided to try the common dialog box and it worked.  I still can't get the thing to print in landscape but I'll be posting another question on that.

Thanks for your help
0
 
LVL 48

Expert Comment

by:Mikal613
ID: 12444750
I have the answer 2 that too when your ready
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

609 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