tc3596
Technical User
- Mar 16, 2001
- 283
Here is my code...
Basically the Userform_Activate kicks off....Calls RunCrystal once, (report pops up and all is well). 2nd report calls RunCrystal and nothing....Any thoughts?
Private Sub UserForm_Activate()
Dim strReports As String
Dim strReportName_1
Dim strReportName_2
Call PEOpenEngine
Dim CrystalJob As Integer
Dim WindowOptions As PEWindowOptions
strReports = Trim(macForm.Tag & "")
OrdNo = Format(SFSOADD.macForm.OrderNo.Text, "00000000")
ItemNo = SFSOADD.macForm.ItemNo.Text
Select Case strReports
Case Is = ""
strReportName_1 = ""
strReportName_2 = ""
Case Is = "P"
strReportName_1 = "Shop Packet"
strReportName_2 = ""
Case Is = "M"
strReportName_1 = ""
strReportName_2 = "Material"
Case Is = "PM"
strReportName_1 = "Shop Packet"
strReportName_2 = "Material"
Case Else
strReportName_1 = ""
strReportName_2 = ""
End Select
If strReportName_1 <> "" Then
v_WhichReport = 1
PrintDest$ = ""
strReportPath = "C:\AutoReports\" & "BirkenShopPckt_Ops_AUTO.rpt"
WindowOptions.StructSize = 32
PEGetWindowOptions CrystalJob, WindowOptions
WindowOptions.hasCloseButton = 1
WindowOptions.hasPrintSetupButton = 1
PESetWindowOptions CrystalJob, WindowOptions
Call RunCrystal("", CrystalJob, "EndJob", 1)
End If
If strReportName_2 <> "" Then
v_WhichReport = 2
PrintDest$ = ""
strReportPath = "C:\AutoReports\" & "BirkenShopPckt_Mats2_AUTO.rpt"
WindowOptions.StructSize = 32
PEGetWindowOptions CrystalJob, WindowOptions
WindowOptions2.hasCloseButton = 1
WindowOptions.hasPrintSetupButton = 1
PESetWindowOptions CrystalJob, WindowOptions
Call RunCrystal("", CrystalJob, "EndJob", 1)
End If
Me.Hide
Set frmProgress = Nothing
End Sub
Public Sub RunCrystal(TextString As String, JobNo As Integer, JobType As String, IndexNo As Integer)
Dim result As Integer
Dim TableLoc As PETableLocation
Dim PrinterMode As DevMode
Dim discard As Boolean
If JobType = "StartJob" Then
JobNo = PEOpenPrintJob(TextString)
discard = PEDiscardSavedData(JobNo)
If v_WhichReport = 1 Then
Call PESetSelectionFormula(JobNo, "{SFDTLFIL_SQL.oper_no} >= 7 and {SFDTLFIL_SQL.rec_type} in ['O', 'T', 'U'] And {SFORDFIL_SQL.ord_no} = '" & OrdNo & "'")
Else
Call PESetSelectionFormula(JobNo, "{SFDTLFIL_SQL.rec_type} <> 'T' and {SFDTLFIL_SQL.oper_seq_no} > 0.00 And {SFORDFIL_SQL.ord_no} = '" & OrdNo & "'")
End If
Exit Sub
End If
If JobType = "SetFile" Then
TableLoc.StructSize = 258
result = PEGetNthTableLocation(JobNo, IndexNo, TableLoc)
TableLoc.tableLocation = TextString & Chr$(0)
result = PESetNthTableLocation(JobNo, IndexNo, TableLoc)
Exit Sub
End If
If JobType = "SetFormula" Then
'CODE FOR SETTING CUSTOM FORMULAS
Exit Sub
End If
If JobType = "EndJob" And PrintDest$ = "" Then
result = PEOutputToWindow(JobNo, "Crystal Reports Preview" & Chr$(0), 100, 100, 490, 300, 0, 0)
ElseIf JobType = "EndJob" Then
result = PEOutputToPrinter(JobNo, 1)
'PrinterMode.dmDeviceName = PrintName$
'PrinterMode.dmSpecVersion = &H320
'PrinterMode.dmSize = 68
'PrinterMode.dmFields = 1
'If IndexNo <> 2 Then IndexNo = 1
'PrinterMode.dmOrientation = IndexNo
'Result = PESelectPrinter(JobNo, PrintDriver$, PrintName$, PrintPort$, PrinterMode)
End If
result = PEStartPrintJob(JobNo, True)
Call PEClosePrintJob(JobNo)
End Sub
Basically the Userform_Activate kicks off....Calls RunCrystal once, (report pops up and all is well). 2nd report calls RunCrystal and nothing....Any thoughts?
Private Sub UserForm_Activate()
Dim strReports As String
Dim strReportName_1
Dim strReportName_2
Call PEOpenEngine
Dim CrystalJob As Integer
Dim WindowOptions As PEWindowOptions
strReports = Trim(macForm.Tag & "")
OrdNo = Format(SFSOADD.macForm.OrderNo.Text, "00000000")
ItemNo = SFSOADD.macForm.ItemNo.Text
Select Case strReports
Case Is = ""
strReportName_1 = ""
strReportName_2 = ""
Case Is = "P"
strReportName_1 = "Shop Packet"
strReportName_2 = ""
Case Is = "M"
strReportName_1 = ""
strReportName_2 = "Material"
Case Is = "PM"
strReportName_1 = "Shop Packet"
strReportName_2 = "Material"
Case Else
strReportName_1 = ""
strReportName_2 = ""
End Select
If strReportName_1 <> "" Then
v_WhichReport = 1
PrintDest$ = ""
strReportPath = "C:\AutoReports\" & "BirkenShopPckt_Ops_AUTO.rpt"
WindowOptions.StructSize = 32
PEGetWindowOptions CrystalJob, WindowOptions
WindowOptions.hasCloseButton = 1
WindowOptions.hasPrintSetupButton = 1
PESetWindowOptions CrystalJob, WindowOptions
Call RunCrystal("", CrystalJob, "EndJob", 1)
End If
If strReportName_2 <> "" Then
v_WhichReport = 2
PrintDest$ = ""
strReportPath = "C:\AutoReports\" & "BirkenShopPckt_Mats2_AUTO.rpt"
WindowOptions.StructSize = 32
PEGetWindowOptions CrystalJob, WindowOptions
WindowOptions2.hasCloseButton = 1
WindowOptions.hasPrintSetupButton = 1
PESetWindowOptions CrystalJob, WindowOptions
Call RunCrystal("", CrystalJob, "EndJob", 1)
End If
Me.Hide
Set frmProgress = Nothing
End Sub
Public Sub RunCrystal(TextString As String, JobNo As Integer, JobType As String, IndexNo As Integer)
Dim result As Integer
Dim TableLoc As PETableLocation
Dim PrinterMode As DevMode
Dim discard As Boolean
If JobType = "StartJob" Then
JobNo = PEOpenPrintJob(TextString)
discard = PEDiscardSavedData(JobNo)
If v_WhichReport = 1 Then
Call PESetSelectionFormula(JobNo, "{SFDTLFIL_SQL.oper_no} >= 7 and {SFDTLFIL_SQL.rec_type} in ['O', 'T', 'U'] And {SFORDFIL_SQL.ord_no} = '" & OrdNo & "'")
Else
Call PESetSelectionFormula(JobNo, "{SFDTLFIL_SQL.rec_type} <> 'T' and {SFDTLFIL_SQL.oper_seq_no} > 0.00 And {SFORDFIL_SQL.ord_no} = '" & OrdNo & "'")
End If
Exit Sub
End If
If JobType = "SetFile" Then
TableLoc.StructSize = 258
result = PEGetNthTableLocation(JobNo, IndexNo, TableLoc)
TableLoc.tableLocation = TextString & Chr$(0)
result = PESetNthTableLocation(JobNo, IndexNo, TableLoc)
Exit Sub
End If
If JobType = "SetFormula" Then
'CODE FOR SETTING CUSTOM FORMULAS
Exit Sub
End If
If JobType = "EndJob" And PrintDest$ = "" Then
result = PEOutputToWindow(JobNo, "Crystal Reports Preview" & Chr$(0), 100, 100, 490, 300, 0, 0)
ElseIf JobType = "EndJob" Then
result = PEOutputToPrinter(JobNo, 1)
'PrinterMode.dmDeviceName = PrintName$
'PrinterMode.dmSpecVersion = &H320
'PrinterMode.dmSize = 68
'PrinterMode.dmFields = 1
'If IndexNo <> 2 Then IndexNo = 1
'PrinterMode.dmOrientation = IndexNo
'Result = PESelectPrinter(JobNo, PrintDriver$, PrintName$, PrintPort$, PrinterMode)
End If
result = PEStartPrintJob(JobNo, True)
Call PEClosePrintJob(JobNo)
End Sub