Dynamic Report Naming (Caption)

  • Thread starter Thread starter LJG
  • Start date Start date
L

LJG

Anyone tell me how I can change the name, (Caption) of a report when it is
run?

I have a report that I want to name as the client name with current date, as
I then save them as a PDF file. I if simply use the same name (caption) each
time It would just overwrite the report each time.

TIA
Les
 
If you want to change the caption of a report, then on the on open property
of the form enter the following code

Me.Caption = "UserName " & Date
 
Les,

The Caption of a report, as far as I know, only determines what is
displayed in the Title Bar of the report when it is previewed. This is
probably not relevant to your problem. It depends on the method you are
using to output the report to pdf. But presumably you are doing this in
code, so whatever you are doing, you should be able to create a string
variable that can be used to assign a unique name ot the pdf file. For
example...
strPdfName = strRept & Format(Date,"yyyymmdd") & ".pdf"
.... where strRept is the name of the report you are currently outputting.
 
Thanks for the help Ofer,

I have been able to change name now, however to make it unique I need to add
company name to the caption and having no luck, please take a look at the
code below and advise were I am going wrong.

Dim strDocName As String

strDocName = [rptQuote]![Company]

Me.Caption = strDocName & "_" & "Proposal" & "_" & UsrName & "_" &
Format(Date, "d,mmmm,yyyy,")
End Sub

Thanks
Les
 
sorry for the delay.
if the problem is that your not getting any value from the Company field, it
could be that putting the code on the on open event is to early, before the
field get the value.
in that case put the code on the on print code of the report header.

If you get an error message then please post the message

LJG said:
Thanks for the help Ofer,

I have been able to change name now, however to make it unique I need to add
company name to the caption and having no luck, please take a look at the
code below and advise were I am going wrong.

Dim strDocName As String

strDocName = [rptQuote]![Company]

Me.Caption = strDocName & "_" & "Proposal" & "_" & UsrName & "_" &
Format(Date, "d,mmmm,yyyy,")
End Sub

Thanks
Les


Ofer said:
If you want to change the caption of a report, then on the on open
property
of the form enter the following code

Me.Caption = "UserName " & Date
 
Les,

I agree with Ofer's comments about the Open event of the report if you
are trying to reference a value from the report's data. But what is
[rptQuote]![Company] supposed to be? This is not normally correct syntax.

And, as I tried to mention in my earlier post, please note that the
Caption of a report is *not* the same as its Name.
 
Thanks Guys,

Everything is working fine now thanks

Steve Schapel said:
Les,

I agree with Ofer's comments about the Open event of the report if you are
trying to reference a value from the report's data. But what is
[rptQuote]![Company] supposed to be? This is not normally correct syntax.

And, as I tried to mention in my earlier post, please note that the
Caption of a report is *not* the same as its Name.

--
Steve Schapel, Microsoft Access MVP

Thanks for the help Ofer,

I have been able to change name now, however to make it unique I need to
add company name to the caption and having no luck, please take a look at
the code below and advise were I am going wrong.

Dim strDocName As String

strDocName = [rptQuote]![Company]

Me.Caption = strDocName & "_" & "Proposal" & "_" & UsrName & "_" &
Format(Date, "d,mmmm,yyyy,")
End Sub

Thanks
Les
 
Back
Top