Unsolved

This post is more than 5 years old

2 Intern

 • 

7.9K Posts

10237

November 6th, 2006 20:00

Using field values in Caption Field / Access 2003

I have a few access reports that routinely get printed to PDF. I've noticed the default filename of the PDF file is the 'caption' value of the report. I can change this value in design view.

I would like to make it dynamic and return field values in the title. Is this possible?

1.7K Posts

November 7th, 2006 10:00

You can use the OnOpen event to write code that will change the title of the report. If you'd like, just reference a field's value and point it to the report title.

If you need a sample, let me know

2 Intern

 • 

7.9K Posts

November 7th, 2006 13:00

sample would be great :)

2 Intern

 • 

7.9K Posts

November 14th, 2006 16:00

bump

1.7K Posts

November 14th, 2006 17:00

Try something like the following if your Title is in the Report Header.  [value] is the field name
 
Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As Integer)
lblTitle.Caption=Me.[value]
End Sub
 
Let me know if this does not work

2 Intern

 • 

7.9K Posts

February 21st, 2007 18:00

not sure if you're still monitoring but that did not work.  said run-time error '424':  Object required

1.7K Posts

February 21st, 2007 19:00

Sorry for the delay - I've been overwhelmed with calls lately.
 
You need to have a label named lblTitle for the code to work.

1.7K Posts

February 21st, 2007 20:00

A real nice feature to trap for no records in a report is to use the NoData event in the report. Just type the following code:
 
    
    MsgBox "No Records to Report"
  Cancel = True
 
If there are no records a message box appears and the report closes.

2 Intern

 • 

7.9K Posts

February 21st, 2007 20:00

thanks again ... I can think of a couple of places where that will be useful :)

2 Intern

 • 

7.9K Posts

February 21st, 2007 20:00

got it ... completely my bad.  I actually had a problem in a source query.  No records meant no value which led to the error.
 
Thanks again :)
 
 
What's interesting is that it only works if I print from print preview.  If I print directly, the file name (and presumably caption) doesn't change.

Top