Senin, 06 Maret 2023

Re: [MSAccessProfessionals] Export to PDF

The codes above worked before. But, now it is returning error 2501 : "OutputTo method was cancelled".
There's nothing changed on the codes. I am confused why it is suddenly returning an error?
Does changing the references affect it?

Please enlighten me.

Ryan

On Wed, 14 Sept 2022 at 03:45, Graham Mandeno via groups.io <graham=mandeno.com@groups.io> wrote:

Hi Paco

strFilter should be used only in the SECOND position (WhereCondition).  The FIRST position (FilterName) should be blank.  It might work having it in both positions, but it is not correct.

According to the documentation here FilterName should be "A string expression that's the valid name of a query in the current database".  As Crystal has pointed out, it is rarely ever used.

Kind regards,
Graham [Access MVP 1996 – 2016]

From: MSAccessProfessionals@groups.io <MSAccessProfessionals@groups.io> On Behalf Of paco@cellarinfo.com
Sent: Wednesday, 14 September 2022 02:55
To: MSAccessProfessionals@groups.io
Subject: Re: [MSAccessProfessionals] Export to PDF

 

Thanks, Paul and Crystal. I see my problem. I use strFilter for both the "name" of the filter AND for the Where Condition. I should have included it twice (in both positions). It's working fine now.

 

Paco

 

From: MSAccessProfessionals@groups.io <MSAccessProfessionals@groups.io> On Behalf Of crystal (strive4peace) via groups.io
Sent: Sunday, September 11, 2022 3:57 AM
To: MSAccessProfessionals@groups.io
Subject: Re: [MSAccessProfessionals] Export to PDF

 

hi Paco,

no, the extra comma needs to go BEFORE the WhereCondition. In reality, the FilterName parameter is barely used.

syntax:

DoCmd.OpenReport ReportName, View, FilterName, WhereCondition, WindowMode, OpenArgs

~ crystal ... more below*

On 9/8/2022 8:45 PM, paco@cellarinfo.com wrote:

Note the extra comma between acViewPreview and strFilter. I think that pushes strFilter to the right position?

previous messages:

~~~

What does strFilter contain?  If it's really a wherecondition, it should be in the next position, like:

 

DoCmd.OpenReport ctllstReport.Column(0, varItem), acViewPreview, , strFilter, acHidden, strOpenArgs 

 

Paul

~~~

 

paco:

I have a VBA function that exports an Access report as a PDF rather than print or preview based on selections on a form. The record source (strFileName), report name (strReportName) and filter (strFilter) are passed to the function from the form. The Preview and Print functionality work fine, but the filter is not applied when outputting to a PDF (even though strFilter contains the proper filer syntax. Any ideas? Thanks in advance.

Private Function Export2PDF (strFileName, strReportName, varItem, strFilter, strOpenArgs) 

    DoCmd.OpenReport ctllstReport.Column(0, varItem), acViewPreview, strFilter, , acHidden, strOpenArgs      'Open the report in preview mode, hidden

    DoCmd.OutputTo acOutputReport, strReportName, acFormatPDF, strFileName, False

    DoCmd.Close acReport, strReportName

End Function

 

~~~

* Paco, when you reply, please include previous messages in the thread so those following can keep up, thanks.

how to Quote Post .. Duane uploaded an image on how to quote post in a reply to show previous messages using the web interface here:

https://groups.io/g/MSAccessProfessionals/photo/249167/2977001

 

kind regards,
crystal

_._,_._,_

Groups.io Links:

You receive all messages sent to this group.

View/Reply Online (#116371) | Reply To Group | Reply To Sender | Mute This Topic | New Topic
Your Subscription | Contact Group Owner | Unsubscribe [sugeng.panjalu.access@blogger.com]

_._,_._,_

Tidak ada komentar:

Posting Komentar