Help with Code

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
 
M

Mark A. Sam

Hello SF,

The help file for OutputTo Action doesn't list .snp as an available format:

OutputTo Action
You can use the OutputTo action to output the data in the specified
Microsoft Access database object (a datasheet, form, report, module, data
access page) to several output formats.

Output Format The type of format you want used to output the data. You
can click HTML (*.htm; *.html), Text Files (*.txt), Microsoft Active Server
Pages (*.asp), Microsoft Excel (*.xls), Microsoft Excel 5-7 (*.xls),
Microsoft Excel 97-10 (*.xls), Microsoft IIS (*.htx, *.idc), Rich Text
Format (*.rtf), Data Access Page (*.htm; *.html) , or XML (*.xml) in the
box.



The help for the OutputTo Method doesn't even list the formats available for
some reason, at least not in A2007 but I am pretty sure that the VBA method
mirrors the Macro Action..

God Bless,

Mark A. Sam
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top