Rabu, 19 Desember 2012

[MS_AccessPros] Re: creating a PDF using record info for name

 

Dan

The report's query should have criteria for the index number taken from the form.

Open the query in deign view and put this in the criteria line for the index:
[Forms}![frmMyForm]![txtMyIndex]

Change frmMyForm and txtMyIndex to match your form name and the control name with the index. This will filter the report based on the index on the form's current record.

Your command button's Click event will look like this:

Private Sub cmdReportToPDF_Click()
Dim strFileName As String

strFileName = "1-" & Format(Me.txtMyIndex, "0000")
DoCmd.OutputTo acOutputReport, "rptCustomers", acFormatPDF, _
"C:\Reports\1-" & strFileName & ".PDF"

End Sub

Again, change Me.txtMyIndex. rptCustomers is the name of the report. Change it to match yours.

Bill

--- In MS_Access_Professionals@yahoogroups.com, Dan Abc <daniel2478a@...> wrote:
>
> Hi Bill,
>
>
> location is the same for this PDF
>
>
>
>
> ________________________________
> From: Bill Mosca <wrmosca@...>
> To: MS_Access_Professionals@yahoogroups.com
> Sent: Monday, December 17, 2012 7:13:29 AM
> Subject: [MS_AccessPros] Re: creating a PDF using record info for name
>
>
>  
> Dan
>
> Is the file location always the same or does the user select a folder?
>
> Regards,
> Bill Mosca, Founder - MS_Access_Professionals
> http://www.thatlldoit.com
> Microsoft Office Access MVP
> https://mvp.support.microsoft.com/profile=C4D9F5E7-BB03-4291-B816-64270730881E
> My nothing-to-do-with-Access blog
> http://wrmosca.wordpress.com
>
> --- In MS_Access_Professionals@yahoogroups.com, Dan Abc <daniel2478a@> wrote:
> >
> > Hi All,
> >
> >
> > I got a form that when it is completed we create a PDF from it
> >
> > currently we do it by printing to PDF or using MS Access to export to PDF
> > and using the form record index
> > eg:
> >
> > for index 123
> > the file name will be "1-0123.PDF"
> >
> >
> > i would like to have a button to do that in one step and place file in certain location
> >
> >
> > what VB code or macro would be required to do that?
> >
> >
> > Thanks in advance
> >
> > Daniel
> >
> > [Non-text portions of this message have been removed]
> >
>
>
>
>
> [Non-text portions of this message have been removed]
>

__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (4)
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar