Dynamic PDF filename on export

I have a function in a basic module that is being called from a custom ribbon tag, for which the code reads:

   strFileName = SaveFileName(strFileType, strFileType, strFileFilter)
   If strFileName <> "" Then
      DoCmd.OutputTo acOutputReport, Screen.ActiveReport.Name, strFileType, strFileName
     
   End If

It works beautifully, however I would like the default filename to be something like "FacListNum" & Me.FacListNum, with FacListNum being the name of a control or field on my report. As it is, it uses the name of the report rather than dynamically naming it according to the value of my field or control. Any help would be appreciated.
Shooter54Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rey Obrero (Capricorn1)Commented:
test this  

strFileName = SaveFileName(strFileType, strFileType, strFileFilter)
   If strFileName <> "" Then

     strFileName=Left(strFileName, instr(strFileName, ".")-1) & "_" & Me.FacListNum & ".pdf"

      DoCmd.OutputTo acOutputReport, Screen.ActiveReport.Name, strFileType, strFileName
     
   End If

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Rey Obrero (Capricorn1)Commented:
or this to make the file type dynamic

  strFileName = SaveFileName(strFileType, strFileType, strFileFilter)

strFileName=Left(strFileName, instr(strFileName, ".")-1) & "_" & Me.FacListNum & mid(strFileName,instrrev(strFileName,"."))


   If strFileName <> "" Then
      DoCmd.OutputTo acOutputReport, Screen.ActiveReport.Name, strFileType, strFileName
     
   End If
Nick67Commented:
Something to try, and to keep in mind.
Reports (and forms) have a .Caption property
Set this in the Open() event of the report and if the user prints to PDF, or saves as PDF, the caption will be the suggested filename.
For Forms, the caption is displayed in the title bar or tab title.  You can mess with that in the Current() event to dynamically update
And, if they are printing to paper, the caption becomes the name of the print job in the printer queue.
That can be a convenience if multiple users are printing to the same printer and the printer can display its queue (like my big Ricohs can) or on the Windows boxes, when you open up a print queue and see what's in there if print jobs are stalled or paused.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.