Including field names in RTF Report filename

M

mstery

How do I include field names in the filename of a report that gets
output to an RTF file? Have a confirmation report that's sent as RTF
via email attachment and want the individual's first/last name to
automatically be included in the report's file name. Base report is
named Confirmation Email, when I use a button/OnOpen event to do:

Dim stDocName As String

stDocName = Me![lastname] & "Confirmation Email"
DoCmd.OpenReport stDocName, acPreview, , "[id]=" & [id]

It gets the last name (i.e., Smith Confirmation Email) in the
filename, but I get an error that says the report is misspelled or
doesn't exist so report won't generate (because there is no report
named "Smith Confirmation Email, I'm guessing). Have also tried to
use an Output To macro in an OnPrint event that includes the last name
field in the path to save to, but no luck. What am I missing? Thanks
in advance.

Madeline
 
G

Guest

You are right. No where is your report name referenced. Also, it looks like
you want to filter the report using the id field. Try this:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = Me![lastname] & "Confirmation Email"

stLinkCriteria = "[id]=" & Me![id]
stDoCmd.OpenReport "Confirmation Email", acPreview, stLinkCriteria

Fred of Guam
 

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