Stephen Lebans PDF code & the WHERE criteria.

  • Thread starter cw via AccessMonster.com
  • Start date
C

cw via AccessMonster.com

Here is my current code behind the Print button on my frmWizard & it works
fine:
---------------------------------------------------------
Private Sub Image370_Click()
On Error GoTo Err_Command370_Click
Dim lstRptName As String
lstRptName = "rptOrderPdf1"
Dim strDocName As String
Dim strID As String
strDocName = Me.ConName
strID = Me.ID
Me.Caption = strDocName & " " & "(CW-" & Format(strID, "00000") & ") New
Order placed on " & Format (Now, " mmmm d yyyy")

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.OpenReport stDocName, acViewPreview

Exit_Command370_Click:
Exit Sub

Err_Command370_Click:
MsgBox Err.Description
Resume Exit_Command370_Click
End Sub
------------------------------------------------------
The query behind the Report links the ID of the frmWizard to the ID of the
rptOrderPdf1.

QUESTION?
----------------
How do I use Stephen Lebans code to output to a PDF based on the ID's ?

I tried to add a Where condition :
-----------------------------------------------------
Private Sub Command459_Click()
Dim lstRptName As String
lstRptName = "rptOrderPdf1"
Dim strDocName As String
Dim strID As String
strDocName = Me.ConName
strID = Me.ID
Me.Caption = strDocName & " " & "(CW-" & Format(strID, "00000") & ") New
Order placed on " & Format(Now, " mmmm d yyyy")
DoCmd.OpenReport lstRptName, acViewPreview, "[ID] = " & Forms![frmWizard]!
[ID] & ""
Call ConvertReportToPDF( lstRptName, vbNullString, lstRptName & ".PDF",
False)
End Sub
--------------------------------------------------
But get error 2501 (OpenReport action was cancelled) & it's stops on the
DoCmd line.

I'm having trouble understanding how to use conditions & Stephens code.
Anyone had any luck?
Here is the code link from Stephen Lebans site:
http://www.lebans.com/reporttopdf.htm

Thanks,
cw
 
D

Douglas J. Steele

Since it's complaining about

DoCmd.OpenReport lstRptName, acViewPreview, "[ID] = " &
Forms![frmWizard]![ID] & ""

I doubt it has anything to do with Stephen's utility.

What datatype is ID? Do you know that you're getting the correct value from
Forms![frmWizard]![ID]?
 
C

cw via AccessMonster.com

ID is an AutoNumber Long Integer.
Since it's complaining about

DoCmd.OpenReport lstRptName, acViewPreview, "[ID] = " &
Forms![frmWizard]![ID] & ""

I doubt it has anything to do with Stephen's utility.

What datatype is ID? Do you know that you're getting the correct value from
Forms![frmWizard]![ID]?
Here is my current code behind the Print button on my frmWizard & it works
fine:
[quoted text clipped - 57 lines]
Thanks,
cw
 
C

cw via AccessMonster.com

I have added this code to my PRINT button:
------------------------------
Private Sub Command459_Click()

Dim stDocName As String
stDocName = "rptOrderPdf1"

DoCmd.OpenReport stDocName, acViewPreview, "[ID] = " & Forms![frmWizard]![ID]
& ""
Call ConvertReportToPDF(stDocName, vbNullString, stDocName & ".PDF", False)

End Sub
-----------------------------
And get the following errors when printing:
Snapshot File Error: Unable to Read SnapShot File. Please Select a different
Report.

Sorry...cannot Parse Snapshot Files. Please Select a different Report to
Export.

Anyone have any ideas ?

ID is an AutoNumber Long Integer.
Since it's complaining about
[quoted text clipped - 11 lines]
 
D

Douglas J. Steele

I'll ping Stephen, and ask him to take a look at this. Hopefully he's over
his flu...



--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



cw via AccessMonster.com said:
I have added this code to my PRINT button:
------------------------------
Private Sub Command459_Click()

Dim stDocName As String
stDocName = "rptOrderPdf1"

DoCmd.OpenReport stDocName, acViewPreview, "[ID] = " &
Forms![frmWizard]![ID]
& ""
Call ConvertReportToPDF(stDocName, vbNullString, stDocName & ".PDF",
False)

End Sub
-----------------------------
And get the following errors when printing:
Snapshot File Error: Unable to Read SnapShot File. Please Select a
different
Report.

Sorry...cannot Parse Snapshot Files. Please Select a different Report to
Export.

Anyone have any ideas ?

ID is an AutoNumber Long Integer.
Since it's complaining about
[quoted text clipped - 11 lines]
Thanks,
cw
 
S

Stephen Lebans

I would suggest the OP read Allen Browne's recent thread on this issue
filters:
http://groups.google.ca/group/micro..._frm/thread/96ed5f6236417003/665f1188c8af50e9

On the errors the OP is seeing,, they are generally caused when the FileName
var contains illegal characters that Windows does not allow for
path/filename.
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


cw via AccessMonster.com said:
I have added this code to my PRINT button:
------------------------------
Private Sub Command459_Click()

Dim stDocName As String
stDocName = "rptOrderPdf1"

DoCmd.OpenReport stDocName, acViewPreview, "[ID] = " &
Forms![frmWizard]![ID]
& ""
Call ConvertReportToPDF(stDocName, vbNullString, stDocName & ".PDF",
False)

End Sub
-----------------------------
And get the following errors when printing:
Snapshot File Error: Unable to Read SnapShot File. Please Select a
different
Report.

Sorry...cannot Parse Snapshot Files. Please Select a different Report to
Export.

Anyone have any ideas ?

ID is an AutoNumber Long Integer.
Since it's complaining about
[quoted text clipped - 11 lines]
Thanks,
cw
 
M

Marshall Barton

cw said:
I have added this code to my PRINT button:
DoCmd.OpenReport stDocName, acViewPreview, "[ID] = " & Forms![frmWizard]![ID]


Nothing to do with the PDF stuff, but there should be two
commas before the WhereCondition argument.
 
C

cw via AccessMonster.com

Thanks to all,

I decided I might have some erroneous code in my database from Stephens first
versions of the PDF mdb/mde so I imported all of my tables/queries/reports
etc into his latest 746 version database.

I tested the report & it printed straight to PDF! Looks Great! Thanks!

Except, My custom Report Title/Report filename did not get captured?

What it should say is : Bob Plater (CW-00016) New Order placed on November
15 2005.pdf
But instead it says : rptOrderPdf1.PDF

My database uses the Windows API calls to hide the Access background & all
forms are Modal/Pop-Up.
I tried putting the Report naming code on the Reports "On Print", On Activate,
On Format, but it still won't change my filename?

Here is my code that produces the custom Report filename:
----------------------------------------------------------
Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As
Integer)
Dim strDocName As String
Dim strID As String
strDocName = Me.ConName
strID = Me.ID
Me.Caption = strDocName & " " & "(CW-" & Format(strID, "00000") & ") New
Order placed on " & Format(Now, " mmmm d yyyy")
End Sub
--------------------------------------------------------
The above code works fine but not with Stephens PDF code. I was using the
PdfCreator open source code & it worked fine & produced my PDF's with the
above filename.

Any ideas would be much appreciated.
Thanks,
cw



Marshall said:
I have added this code to my PRINT button:
DoCmd.OpenReport stDocName, acViewPreview, "[ID] = " & Forms![frmWizard]![ID]

Nothing to do with the PDF stuff, but there should be two
commas before the WhereCondition argument.
 

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