Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Report stays locked and Access does not close properly

Status
Not open for further replies.

JordanCN

IS-IT--Management
Apr 12, 2006
77
US
I have an Access 2003 project that is using Crystal Reports 8. I added the GLOBAL32.BAS to my Access MDB file which uses declares of CRPE32.DLL to expose the Crystal report functions.

I have a function that calls a report on the file server and passes a selection criteria which seems to work well, however I see on the file server that for every time I run the report there is a lock on the .rpt file. Even when I move the rpt file to the local computer it still keeps a lock.

Even when I close the Access MDB file I can see in Task Manager that Access still has not closed. In order to kill off the lock I have to CTRL+ALT+DEL and kill Access.

Most likely I am not closing the report properly which is why Access does not fully close and the locks on the file remain. Here is my function:

+++++++++++++

Public Function PrintSalesOrderLabel(strSalesOrder As String)

Dim Result%
Dim SelectionText$
Dim jobnum%
Dim SalesOrderWindowOptions As PEWindowOptions

On Error GoTo Err_PrintSalesOrder


SelectionText$ = "{SO Master.ORDNUM_27} = '" & strSalesOrder & "'"

Result% = PEOpenEngine()
If Result% = 0 Then
MsgBox "Could not start the report engine. Execution must halt.", vbOKOnly + vbCritical, "Serious Error"
End
End If

jobnum% = PEOpenPrintJob("M:\MAX\dat\sls059.rpt")
If jobnum% = 0 Then
MsgBox "Sales Order Report missing"
End If

Result% = PESetSelectionFormula(jobnum%, SelectionText$)
If Result% = 0 Then
MsgBox "Report may be damaged, changed, or missing. Check report file.", , "Report Problem"
End
End If

With SalesOrderWindowOptions
.StructSize = 26
.hasPrintSetupButton = 1
.hasCancelButton = 1
.hasExportButton = 1
.hasNavigationControls = 1
.hasPrintButton = 1
.hasZoomControl = 1
End With
Result% = PESetWindowOptions(jobnum%, SalesOrderWindowOptions)
Result% = PEOutputToWindow(jobnum%, "Sales Order" & Chr$(0), CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 0, 0)
Result% = PEStartPrintJob(jobnum%, True)

Exit_PrintSalesOrder:
Exit Function

Err_PrintSalesOrder:
MsgBox Err.Description, , Err.Number
Resume Exit_PrintSalesOrder:

End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top