how can i pass parameter to print access report by giving parameter as Report File Name,Query,Prin terName,Number of copies to be print
my code is
my code is
Code:
Function fPrintRemoteReport(strMDB As String, _
strReport As String, _
rptPrinter As String, _
numCopies As Integer, _
Optional intView As Variant) _
As Boolean
Dim objAccess As Access.Application
Dim lngRet As Long
On Error GoTo fPrintRemoteReport_Err
strQuery = "SELECT Can1Z_Orders.* From Can1Z_Orders INNER JOIN ItemsPrinterTable ON Can1Z_Orders.UpsItemNumber = ItemsPrinterTable.UpsItemNumber " & _
" WHERE (((DateToPrint) Is Null) AND ((DetailInd)= 'pp' )) AND Can1Z_Orders.AutoID=" & GetAutoID()
Set conn = modCommon.createConnection(App.Path & "\UPSThermalLabels.accdb")
conn.Execute ("Delete from CSW_Orders_Temp ")
conn.Close
Set conn = Nothing
Set conn = modCommon.createConnection(App.Path & "\UPSThermalLabels.accdb")
conn.Execute ("insert into CSW_Orders_Temp " & strQuery)
conn.Close
Set conn = Nothing
If Len(Dir(strMDB)) > 0 Then
Set objAccess = New Access.Application
With objAccess
.OpenCurrentDatabase strMDB
.DoCmd.SelectObject acReport, strReport, True
.DoCmd.PrintOut acPrintAll, , , , numCopies, False
End With
objAccess.Quit
Set objAccess = Nothing
End If
fPrintRemoteReport_Exit:
On Error Resume Next
objAccess.Quit
Set objAccess = Nothing
Exit Function
fPrintRemoteReport_Err:
fPrintRemoteReport = False
Select Case err.Number
Case 7866:
'mdb is already exclusively opened
MsgBox "The database you specified " & vbCrLf & strMDB & _
vbCrLf & "is currently open in exclusive mode. " & vbCrLf _
& vbCrLf & "Please reopen in shared mode and try again", _
vbExclamation + vbOKOnly, "Could not open database."
Case 2103:
'Report doesn't exist
MsgBox "The Report '" & strReport & _
"' doesn't exist in the Database " _
& vbCrLf & strMDB, _
vbExclamation + vbOKOnly, "Report not found"
Case 7952:
fPrintRemoteReport = True
End Select
Resume fPrintRemoteReport_Exit
End Function