I have a method that uses a temporary table (PRNTSOFM.DB), along with the static tables, to print a report. The code is listed below. The user can activate this code for different data one after the other. When a large number of reports have built up, some reports are not printed, and most of the time, there will be a GPF generated. I believe that what is happening is that the temporary table is getting deleted before the previous report is finished using it. Is there any way to prevent a return from this method until the report is no longer using the temporary table? I already tried assigning the statement "rpt.print(PrintInfo_RPI)" to a logical value, but it didn't seem to help. I also tried using "printlock" report restart options, but that didn't work because the other tables used by the report can be locked by other users. I'd appreciate any help I can get. I did not write this method, and I'm not an expert with Paradox. Thanks !
method printServiceOrderForm(CONST ThisPremiseID_LI LONGINT,
CONST ThisServiceRequestID_LI LONGINT,
CONST CloseTcursors_L LOGICAL) LOGICAL
VAR
ReturnVal_L LOGICAL
Answer_TBL TABLE
ReportFile_S,ReqType_S STRING
prnoptions PRINTEROPTIONINFO
openinfo REPORTOPENINFO
PrintInfo_RPI REPORTPRINTINFO
rpt REPORT
ENDVAR
ReturnVal_L = False ;Assume problems
IF NOT Servcord_TC.isAssigned() THEN
IF NOT Servcord_TC.open(DataAlias_S + "SERVCORD" THEN
RETURN ReturnVal_L
ENDIF
IF IsTable("RIVRNTSOFM.DB" THEN
delete("RIVRNTSOFM.DB"
ENDIF
Answer_TBL = CREATE "RIVRNTSOFM.DB"
LIKE Servcord_TC
ENDCREATE
IF NOT Answer_TBL.isAssigned() THEN
errorShow("Unable to create Answer"
DEBUG()
ENDIF
Answer_TC.open(Answer_TBL)
Answer_TC.edit()
ENDIF
IF Servcord_TC.qLocate(ThisPremiseID_LI,
ThisServiceRequestID_LI) THEN
ReqType_S = "/" + Servcord_TC."NSR-REQ-TYPE" + "/"
SWITCH
CASE Search("/E/O/U/C/M/P/S/EW/OW/UW/",ReqType_S) <> 0:
;Electric service orders
ReportFile_S = ":WRSSYS:R\\Mrktinpt-Elec.RSL"
; Use constant to specify orientation.
prnOptions.Orientation = prnPortrait
PrintInfo_RPI.orient = PrintPortrait
CASE Search("/T/TR/T1/T1R",ReqType_S) <> 0:
ReportFile_S = ":WRSSYS:R\\Mrktinpt-TSS.RSL"
; Use constant to specify orientation.
prnOptions.Orientation = prnPortrait
PrintInfo_RPI.orient = PrintPortrait
OTHERWISE:
;Unknown type
msgInfo("Print List",
"Request Type: " + Servcord_TC."NSR-REQ-TYPE" + "\n\n" +
"Request type not found. Using Electric form."
ReportFile_S = ":WRSSYS:R\\Mrktinpt-Elec.RSL"
; Use constant to specify orientation.
prnOptions.Orientation = prnPortrait
PrintInfo_RPI.orient = PrintPortrait
ENDSWITCH
Answer_TC.deleteRecord() ;Clear last record
Answer_TC.insertRecord(Servcord_TC)
Answer_TC.postRecord()
PrintInfo_RPI.Name = ReportFile_S
PrintInfo_RPI.MasterTable = "RIVRNTSOFM.DB"
if printerSetOptions(prnOptions) then
rpt.print(PrintInfo_RPI)
else
errorShow("Could not set printer options--Viewing instead."
openinfo.name = ReportFile_S
openinfo.mastertable = "RIVRNTSOFM.DB"
openinfo.WinStyle = WinStyleDefault+WinStyleHidden
viewReport(openinfo)
sleep(50)
endIf
ReturnVal_L = True
ELSE
beep()
msgInfo("Print Service Order Form",
"Premise ID: " + ThisPremiseID_LI.string() + "\n" +
"SO Request#: " + ThisServiceRequestID_LI.string() + "\n\n" +
"Unable to locate service order request."
ENDIF
IF CloseTcursors_L THEN
Servcord_TC.close()
Answer_TC.close()
ENDIF
RETURN ReturnVal_L
endMethod
method printServiceOrderForm(CONST ThisPremiseID_LI LONGINT,
CONST ThisServiceRequestID_LI LONGINT,
CONST CloseTcursors_L LOGICAL) LOGICAL
VAR
ReturnVal_L LOGICAL
Answer_TBL TABLE
ReportFile_S,ReqType_S STRING
prnoptions PRINTEROPTIONINFO
openinfo REPORTOPENINFO
PrintInfo_RPI REPORTPRINTINFO
rpt REPORT
ENDVAR
ReturnVal_L = False ;Assume problems
IF NOT Servcord_TC.isAssigned() THEN
IF NOT Servcord_TC.open(DataAlias_S + "SERVCORD" THEN
RETURN ReturnVal_L
ENDIF
IF IsTable("RIVRNTSOFM.DB" THEN
delete("RIVRNTSOFM.DB"
ENDIF
Answer_TBL = CREATE "RIVRNTSOFM.DB"
LIKE Servcord_TC
ENDCREATE
IF NOT Answer_TBL.isAssigned() THEN
errorShow("Unable to create Answer"
DEBUG()
ENDIF
Answer_TC.open(Answer_TBL)
Answer_TC.edit()
ENDIF
IF Servcord_TC.qLocate(ThisPremiseID_LI,
ThisServiceRequestID_LI) THEN
ReqType_S = "/" + Servcord_TC."NSR-REQ-TYPE" + "/"
SWITCH
CASE Search("/E/O/U/C/M/P/S/EW/OW/UW/",ReqType_S) <> 0:
;Electric service orders
ReportFile_S = ":WRSSYS:R\\Mrktinpt-Elec.RSL"
; Use constant to specify orientation.
prnOptions.Orientation = prnPortrait
PrintInfo_RPI.orient = PrintPortrait
CASE Search("/T/TR/T1/T1R",ReqType_S) <> 0:
ReportFile_S = ":WRSSYS:R\\Mrktinpt-TSS.RSL"
; Use constant to specify orientation.
prnOptions.Orientation = prnPortrait
PrintInfo_RPI.orient = PrintPortrait
OTHERWISE:
;Unknown type
msgInfo("Print List",
"Request Type: " + Servcord_TC."NSR-REQ-TYPE" + "\n\n" +
"Request type not found. Using Electric form."
ReportFile_S = ":WRSSYS:R\\Mrktinpt-Elec.RSL"
; Use constant to specify orientation.
prnOptions.Orientation = prnPortrait
PrintInfo_RPI.orient = PrintPortrait
ENDSWITCH
Answer_TC.deleteRecord() ;Clear last record
Answer_TC.insertRecord(Servcord_TC)
Answer_TC.postRecord()
PrintInfo_RPI.Name = ReportFile_S
PrintInfo_RPI.MasterTable = "RIVRNTSOFM.DB"
if printerSetOptions(prnOptions) then
rpt.print(PrintInfo_RPI)
else
errorShow("Could not set printer options--Viewing instead."
openinfo.name = ReportFile_S
openinfo.mastertable = "RIVRNTSOFM.DB"
openinfo.WinStyle = WinStyleDefault+WinStyleHidden
viewReport(openinfo)
sleep(50)
endIf
ReturnVal_L = True
ELSE
beep()
msgInfo("Print Service Order Form",
"Premise ID: " + ThisPremiseID_LI.string() + "\n" +
"SO Request#: " + ThisServiceRequestID_LI.string() + "\n\n" +
"Unable to locate service order request."
ENDIF
IF CloseTcursors_L THEN
Servcord_TC.close()
Answer_TC.close()
ENDIF
RETURN ReturnVal_L
endMethod