Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I set a report title within VBA

Status
Not open for further replies.

devGarfield

Programmer
Mar 23, 2004
31
GB
Hi,

I have an Access form that has a number of checkboxs. These
checkboxes determine the db query that is built using CreateQueryDef. I then run a report based on the query. 5 reports can be created, but with different titles. No point in having 5 different reports when 1 generic one will do.

I want to set the report title based on the options checked . I've tried to set it when the query is being built, but I don't have the options to do so. I tried to change the report title in the load_report event but that didn't work either.

Any suggestions would be helpful.

Regards
Garfield
 
For this, you could include the title as a field in the query.

EG ,

Select "Report Name" as reportname, price, quantity
from table1

Or, you could have the value as a hidden field on the form and then simply include a reference to the form on the report.
 
Try changing the Reports Title in the ReportHeader_Format event. In the Design view of the report, add a label for the Report's title. Then in the ReportHeader_Format event, try the following
Code:
If Report.RecordSource = "recordsource 1" Then
Label25.Caption = "Hello"
Else
If Report.RecordSource = "recordsource 2" Then
Label25.Caption = "Hi There"
End If
 
Hi mdav,

This can work, however the query generates quite a few records and having the reportname on each is not something I would like, but it can work.

Thanks again.

Hi EliseFreedman,

All the 5 reports have the same record source so there is no way on distinguishing them at that stage.

Thanks

What I would really like is to set a global variable and assign that to the report when it runs. But that also was giving problems.

Garfield
 
You should be able to use the same method to test the values of the check boxes and change the report heading depending on which check boxes have their values set to true
 
Hi EliseFreedman,

I tried to set the caption value within the ReportHeader_Format event. But I the caption property is not present, so I can't see it to set it.

Garfield
 
Hi Again,

I've resolved my small problem, by creating a public variable and setting the value appropriately. Then in the ReportHeader_Format event set the label to the public variable. e.g. lblTitle = pvarReportTile

Thanks for all contributions

Garfield
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top