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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

View report as PDF 1

Status
Not open for further replies.

Hafa1961

Technical User
Aug 15, 2006
18
IE
Using Access 2000 and need help opening report as a PDF using Lebans A2000ReportToPDF which uses this code to open a report in a listbox of a form:

Private Sub cmdReportToPDF_Click()

Dim blRet As Boolean
blRet = ConvertReportToPDF(Me.lstRptName, vbNullString, _
Me.lstRptName.Value & ".pdf", False, True, 150, "", "", 0, 0, 0)

End Sub


But I need to modify this code to open a report from a command button.

Currently code behind command button:

Private Sub cmdDelDocket_Click()
On Error GoTo Err_cmdDelDocket_Click

strDocName = "repDeliveryDocketSingle"
DoCmd.OpenReport strDocName, acViewPreview

Exit_cmdDelDocket_Click:
Exit Sub

Err_cmdDelDocket_Click:
MsgBox Err.Description
Resume Exit_cmdDelDocket_Click
End Sub

I am not that proficient in VB coding yet and would
greatly appreciate any assistance or direction.

 
I think you want to open the report selected in the list box
Code:
Private Sub cmdDelDocket_Click()
On Error GoTo Err_cmdDelDocket_Click
If Not IsNull(Me.lstRptName) Then
    strDocName = Me.lstRptName
    DoCmd.OpenReport strDocName, acViewPreview
 Else
    MsgBox "Select a report",vbOKOnly + vbInformation, "PEBKAC"
End If
Exit_cmdDelDocket_Click:
    Exit Sub

Err_cmdDelDocket_Click:
    MsgBox Err.Description
    Resume Exit_cmdDelDocket_Click
End Sub

Duane
Hook'D on Access
MS Access MVP
 
Hi Duane,
Thanks for the feedback, although I don't think this is what I am looking for.

I basically have a form with a cmdButton that when clicked
previews the report for this record. Once in preview I send this via email in either rtf or snp form.

But instead of previewing this report in native Access Report Format I would like to preview it in PDF and then be able to send as a attachment by email.

Lebans( generates this PDF report by first selecting from a listbox on a form AND previewing in PDF.

My form does not use a listbox to generate a report for a record, just the following code that calls to preview the report.

strDocName = "repDeliveryDocketSingle"
DoCmd.OpenReport strDocName, acViewPreview

I have tried the following but am getting a variable code error.

Private Sub cmdDelDocket_Click()
Dim strDocName As String
Dim blRet As Boolean

strDocName = "repDeliveryDocketSingle"
blRet = ConvertReportToPDF(repDeliveryDocketSingle)

End Sub


But as you can see I haven't a clue as to VB coding.
 
I don't know what all the ConverReportToPDF does but this might get you closer:
Code:
Dim blRet As Boolean
Dim strDocName As String

strDocName = "repDeliveryDocketSingle"

blRet = ConvertReportToPDF(strDocName, vbNullString, _
strDocName & ".pdf", False, True, 150, "", "", 0, 0, 0)

Duane
Hook'D on Access
MS Access MVP
 
Duane,
You are a life-saver, works perfect.
I was getting close with this code except I still could not preview the report. Yours was right on the money.

blRet = ConvertReportToPDF("repDeliveryDocketSingle", vbNullString, "C:\Access\repDeliveryDocketSingle" & ".pdf", False, False)

Many thanks for your help
Greatly appreciated
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top