Dynamicaly change name of report

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using Primo PDf to save a report called Order Form as a pdf file. Primo
wants to save it as Order.pdf but I want it to save as the name of the
customer,

is their anyway in the code to change that name once I have called it

DocName = "Order Form"
DoCmd.OpenReport DocName, acNormal, , LinkCriteria

becomes

DocName = "Order Form" ----- actual name
DoCmd.OpenReport DocName, acNormal, , LinkCriteria -------- open the
report but change the name

Thanks
 
Hi, Nigel.
is their anyway in the code to change that name once I have called it

No. Once the object is open, the name of the object cannot be changed. The
object must be closed when the name is changed. However, the name of the
object can be changed _before_ actually opening it. For example:

DoCmd.Rename "CustomerName", acReport, "Order Form"
DoCmd.OpenReport "CustomerName", acViewNormal, , LinkCriteria

.... where Order Form was the original name of the report, CustomerName is
the new name of the report, and LinkCriteria is the string variable for the
WHERE clause.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 
That will work, but now you have lost the original name, and future
references will not find the report. I would suggest:
Copy the report object to the new name
Open the report using the new name
Delete the report using the new name
 
wil this work if the file is an mde file?

Klatuu said:
That will work, but now you have lost the original name, and future
references will not find the report. I would suggest:
Copy the report object to the new name
Open the report using the new name
Delete the report using the new name
 
Hi.
That will work, but now you have lost the original name

Good point, but that's exactly what he asked for. Either we can assume that
he knows what he's doing (the "Order Form" name of the original object
suggests a report made from a copy of a form -- either via VBA code or via
the GUI "Save As... Report" option in the Database Window) or we can assume
otherwise.

I chose to give him the benefit of the doubt.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.
 
Good question, Nigel. Sorry, but I don't really know the answer. Maybe
someone with more knowledge than I can answer that question or you could do a
test on it.
 
Hi, Nigel.
wil this work if the file is an mde file?

No. One cannot create, rename, or delete reports, forms, or modules in MDE
database files. You'll need to use an MDB database file if you need this
flexibility. However, it's probably easiest to just rename the resulting PDF
file after it's been saved in the directory.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 
Thanks I unedrstand the VBA, I was trying to make it easier for the users,
THe end result is that they will have to save the pdf file as the name they
want
 
Back
Top