S
SF
Hi,
I have a form use to print and export report of multiple contract to PDF. I
have a combobox to store report name and a listbox to list ContractID
(listContractID). I have a variable (gstrReportFilter) for filtering my
report on open, this is why I try to assisgn Ck_ContractID so that everytime
a report is opened, a filter is appl;y.
I come up with code below- It does not work cause it does not generate
'Report Snapshot'. There is no error message, but the code below does not
appear to be working. Could someone help me?
SF
Dim RptName As String
Dim blRet As Boolean
Dim sPDF As String
Dim DirStg As String
Dim strPathandFileName As String
Dim VarAns As Variant
Dim msgStg As String
Dim varPDFPath As String
Dim DocName As String
Dim VarItem As Variant
DirStg = Me.txtPATH '"R:\FOG Agreement\" & Me.Partner.Column(1)
If FolderExists(Me.txtPATH) = False Then
MkDir DirStg
End If
For Each VarItem In Me.listContractID.ItemsSelected
If Me.cmbDoc = "rptSDFGrandAgreement_e" Then
strPathandFileName = "C:\" & Me.listContractID.ItemData(VarItem)
& ".snp"
gstrReportFilter = "Ck_ContractID ='" &
Me.listContractID.ItemData(VarItem) & "'"
DoCmd.OutputTo acOutputReport, Me.cmbDoc,
"SnapshotFormat(*.snp)", strPathandFileName
sPDF = DirStg & "\" & Me.listContractID.ItemData(VarItem) &
"_(Eng)"
ElseIf Me.cmbDoc = "rptSDFGrandAgreement_k" Then
strPathandFileName = "C:\" & Me.listContractID.ItemData(VarItem)
& ".snp"
DoCmd.OutputTo acOutputReport, Me.cmbDoc,
"SnapshotFormat(*.snp)", strPathandFileName
sPDF = DirStg & "\" & Me.listContractID.ItemData(VarItem) &
"_(Khm)"
ElseIf Me.cmbDoc = "rptSDFAgreementMileStones_k" Then
strPathandFileName = "C:\" & Me.listContractID.ItemData(VarItem)
& ".snp"
DoCmd.OutputTo acOutputReport, Me.cmbDoc,
"SnapshotFormat(*.snp)", strPathandFileName
sPDF = DirStg & "\Milestone-" &
Me.listContractID.ItemData(VarItem) & "_(Khm)"
End If
Debug.Print "strPathandFileName =" & strPathandFileName
Debug.Print "gstrReportFilter = " & gstrReportFilter
gstrReportFilter = ""
Next VarItem
varPDFPath = sPDF & ".PDF"
blRet = ConvertReportToPDF(vbNullString, strPathandFileName, varPDFPath,
False, False, , , , , 0)
Kill strPathandFileName
DoCmd.Beep
I have a form use to print and export report of multiple contract to PDF. I
have a combobox to store report name and a listbox to list ContractID
(listContractID). I have a variable (gstrReportFilter) for filtering my
report on open, this is why I try to assisgn Ck_ContractID so that everytime
a report is opened, a filter is appl;y.
I come up with code below- It does not work cause it does not generate
'Report Snapshot'. There is no error message, but the code below does not
appear to be working. Could someone help me?
SF
Dim RptName As String
Dim blRet As Boolean
Dim sPDF As String
Dim DirStg As String
Dim strPathandFileName As String
Dim VarAns As Variant
Dim msgStg As String
Dim varPDFPath As String
Dim DocName As String
Dim VarItem As Variant
DirStg = Me.txtPATH '"R:\FOG Agreement\" & Me.Partner.Column(1)
If FolderExists(Me.txtPATH) = False Then
MkDir DirStg
End If
For Each VarItem In Me.listContractID.ItemsSelected
If Me.cmbDoc = "rptSDFGrandAgreement_e" Then
strPathandFileName = "C:\" & Me.listContractID.ItemData(VarItem)
& ".snp"
gstrReportFilter = "Ck_ContractID ='" &
Me.listContractID.ItemData(VarItem) & "'"
DoCmd.OutputTo acOutputReport, Me.cmbDoc,
"SnapshotFormat(*.snp)", strPathandFileName
sPDF = DirStg & "\" & Me.listContractID.ItemData(VarItem) &
"_(Eng)"
ElseIf Me.cmbDoc = "rptSDFGrandAgreement_k" Then
strPathandFileName = "C:\" & Me.listContractID.ItemData(VarItem)
& ".snp"
DoCmd.OutputTo acOutputReport, Me.cmbDoc,
"SnapshotFormat(*.snp)", strPathandFileName
sPDF = DirStg & "\" & Me.listContractID.ItemData(VarItem) &
"_(Khm)"
ElseIf Me.cmbDoc = "rptSDFAgreementMileStones_k" Then
strPathandFileName = "C:\" & Me.listContractID.ItemData(VarItem)
& ".snp"
DoCmd.OutputTo acOutputReport, Me.cmbDoc,
"SnapshotFormat(*.snp)", strPathandFileName
sPDF = DirStg & "\Milestone-" &
Me.listContractID.ItemData(VarItem) & "_(Khm)"
End If
Debug.Print "strPathandFileName =" & strPathandFileName
Debug.Print "gstrReportFilter = " & gstrReportFilter
gstrReportFilter = ""
Next VarItem
varPDFPath = sPDF & ".PDF"
blRet = ConvertReportToPDF(vbNullString, strPathandFileName, varPDFPath,
False, False, , , , , 0)
Kill strPathandFileName
DoCmd.Beep