OutputTo

T

Tom

Hi all,
I have a command button that output a report called invoice to word.
it prompt me for the format and I choose rtf.
I want that the name of the rtf file will be the customer name from either
the report or the form.
I tried to play with the parameters and with the RepName but it didn't work.
Here is what I have:

Dim RepName as string
RepName = "Invoice"
DoCmd.OutputTo acReport, RepName
TIA,

Tom
 
T

Tom Wickerath

Hi Tom,

Try something like this for a hard-coded path. Substitute CustomerName with
the name of the field on your form that displays the customer's name:

DoCmd.OutputTo acReport, "Invoice", acFormatRTF, _
"C:\Temp\" & Me.CustomerName & ".rtf"

Note: You really do not need to declare the variable RepName; you can just
include the name of the report, as indicated above. If you'd like to output
the report to the same folder that the .mdb file is located in, then use this
variation instead:

DoCmd.OutputTo acReport, "Invoice", acFormatRTF, _
CurrentProject.Path & "\" & Me.CustomerName &
".rtf"



Tom Wickerath
Microsoft Access MVP

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________
 
T

Tom

Thanks,
I also need to add to the file name the date of purchase form field
"DateofPurchase",
I hope it's possible.
Tia,
Tom
 
T

Tom Wickerath

Here are some variations for you to try:

Leading Date:

DoCmd.OutputTo acReport, "Invoice", acFormatRTF, _
CurrentProject.Path & "\" & Format(Me.OrderDate, "yyyy_mmm_dd") _
& "_" & Me.CustomerName & ".rtf"

DoCmd.OutputTo acReport, "Invoice", acFormatRTF, _
CurrentProject.Path & "\" & Format(Me.OrderDate, "mm_dd_yyyy") _
& "_" & Me.CustomerName & ".rtf"


Trailing Date:

DoCmd.OutputTo acReport, "Invoice", acFormatRTF, _
CurrentProject.Path & "\" & Me.CustomerName _
& "_" & Format(Me.OrderDate, "yyyy_mmm_dd") & ".rtf"


Tom Wickerath
Microsoft Access MVP

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________
 

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