Export and automatic rename a report (1 Viewer)

underc

New member
Local time
Today, 23:18
Joined
Nov 2, 2013
Messages
6
Hello everyone.
I need some help in access 2010.

I have a report (FI_ID) based in a query with the same name.
When i export this report to my desktop i need to manualy rename the filename.
What i need is a way to automatic rename my report to my text field value, called "Seq_Number" (it's a automatic number).
At the end i will have 101.pdf, 102.pdf, 103.pdf in my desktop.
Thank you.
 

AlexHedley

Registered User.
Local time
Today, 23:18
Joined
Aug 28, 2012
Messages
171
How are you exporting the report?
Are you using VBA?
Are you using a Macro?
Are you using the a Ribbon button?
 

underc

New member
Local time
Today, 23:18
Joined
Nov 2, 2013
Messages
6
Hello AlexHedley, thanks for your reply.

I´m using a macro, but don´t know where and how to get the field value...

So i try to do it with VBA, but got the same problem... don´t know how to get the field value in the report called "Seq_Number".

1. DoCmd.OpenReport "FI_ID", acViewPreview, "", "", acNormal
2. DoCmd.OutputTo acOutputReport, "", "PDFFormat(*.pdf)", "", False, "", , acExportQualityPrint

I don´t need to open the report, just to export in PDF format to my desktop with the name of my field value (Seq_number).

Thanks for your time.
 

AlexHedley

Registered User.
Local time
Today, 23:18
Joined
Aug 28, 2012
Messages
171
You can refer to a control on a Form and then use it on the Filename when you export

Dim strPathAndFile As String
strPathAndFile = "C:/.../filename_" & CONTROLNAME &".pdf"
DoCmd.OutputTo acOutputReport, "rptNAME", acFormatPDF, strPathAndFile, True
 

underc

New member
Local time
Today, 23:18
Joined
Nov 2, 2013
Messages
6
I don´t really know how to do that.
I need a button in a simple form (without records) that when pressed will open the "FI_ID" Report based in a Query. Then automatic save it (export) in PDF format with the name of a field value in that report. If the field value is Tom it must save the file as "TOM.pdf", if the field value is John it will save as "John.pdf".
Hope you can help me with an example. Thanks
 

AlexHedley

Registered User.
Local time
Today, 23:18
Joined
Aug 28, 2012
Messages
171
DoCmd.OpenReport "rptNAME"

Run export cmd below.

DoCmd.Close acReport, "rptNAME"

- -
expression.OpenReport(ReportName, View, FilterName, WhereCondition, WindowMode, OpenArgs)
 

underc

New member
Local time
Today, 23:18
Joined
Nov 2, 2013
Messages
6
I've done this in a form

Dim strPathAndFile As String
strPathAndFile = "C:\Users\Name\Desktop\" & Seq_number & ".pdf"
DoCmd.OutputTo acOutputReport, "FI_IDs", acFormatPDF, strPathAndFile, False

The problem is that i must be in a form with a record open like "101"
When i run the code, it will pop up my Query (parameter dialog box) that will ask for a field value. If i choose other than 101 (the one it's open), let's say 201 it will export to pdf the 201 but with the filename 101.pdf.
Only need to save the filename which is entered in the parameter dialog box without the need to be in a form with the records open.
Sounds confuse...
Thanks for your time
 

AlexHedley

Registered User.
Local time
Today, 23:18
Joined
Aug 28, 2012
Messages
171
You could link the Query Parameter to the control on the Form.
Add a textbox to the Form called "txtSeq_number".

Then in the Query add the Criteria of:
FORMS!frmName!txtSeq_number

Now when you choose a "Seq_number" it will use that in the Query, export it and be the correct name.
 

underc

New member
Local time
Today, 23:18
Joined
Nov 2, 2013
Messages
6
Hi AlexHedley

This is a nice way of doing what i want. :)

Thank you for your time!
 

Users who are viewing this thread

Top Bottom