I'm using VB6 SP5 and the Crystal Reports OCX to produce some output from a recordset. If the user chooses to send the output directly to the printer rather than display it then I use the CommonDialog ShowPrinter method to pop up a printer dialog box before sending the output to the printer. My problem is that the printer dialog is not always displayed, either running from the IDE or running the compiled application and I can't figure out why. Sometimes closing the program then launching it again fixes the problem temporarily, sometimes restarting the PC cures it and sometimes nothing seems to work. Here is the pertinent code, which resides in a Sub in a module that I'm calling from the Click event of a command button on the main form:
Any suggestions how to resolve this would be greatly appreciated.
Code:
With frmMain.CrystalReport1
.SetTablePrivateData 0, 3, rs
.ReportFileName = ReportName
.DiscardSavedData = True
.WindowTitle = WindowTitle
.WindowState = crptNormal
If HardCopy = False Then
.Destination = 0 ' To Screen
Else
.Destination = 1 ' To Printer
Select Case Right$(ReportName, Len(ReportName) - InStrRev(ReportName, "\"))
Case "EpayFullBatch.rpt", "CollectionLetter.rpt"
MsgBox "Choose plain-paper printer or load plain paper", vbExclamation
Case "EpayChecks.rpt"
MsgBox "Choose check printer or load check paper", vbCritical
End Select
frmMain.Dialog1.ShowPrinter
End If
.Action = 1
End With