Part of creating a professional Access application is paying attention to the details.
One example of this is defining captions for your forms and reports. If you don't define a caption, Access will display the object's name. That's not what you want, as the names of your forms and reports should follow a developer-friendly naming convention.
A good developer-friendly naming convention will not be user-friendly.
Consider these common object naming conventions:
- No spaces in object names (e.g.,
- Short object-specific prefixes (e.g.,
- Abbreviations to keep names short (e.g.,
Showing any of the above names to your users is not the end of the world, but it makes your application look unpolished.
The Report Caption Property
Microsoft Access provides us with a report Caption property to address this issue:
Gets or sets the title of the report in Print Preview.
In addition to setting the title of the report in Print Preview, it also becomes the default file name when a user saves a report to PDF via a virtual printer, such as PDFCreator.
It's Easy to Forget
I've lost count of how many times over the years that I've forgotten to set this property.
I usually realize my mistake while demonstrating the new report to the end user and it irks me every time. After at least the dozenth time (is that a word?), I decided to finally do something about it.
My solution was to change the report's heading text from a Label control to a Textbox control and set the Textbox control equal to the report's caption property.
- Create a text box in your Report Header or Page Header.
- Set its ControlSource to
- Set the report's Caption property in the Property Sheet
Of course, you still need to remember to set the report's Caption property. But now if you forget, the mistake will be glaringly obvious, as there will be a big empty spot where the report's title should appear.
Especially Handy for Report Templates
This trick comes in especially handy on a report template.
You can style the
=Report.Caption text box (font, size, position, etc.) exactly the way you want it in your template. Then, when you create a new report from the template, the report's title will already be formatted and ready to go. All you have to do is set the report's Caption property.
Personally, I use a function I wrote called
DesignNewReport which generates new reports from scratch, using the same approach as in my DesignNewForm function.
Here's the relevant excerpt from my
With CreateReportControl(Rpt.Name, acTextBox, acPageHeader) .FontSize = 14 .FontName = "Arial" .FontBold = True .TextAlign = 2 'Center .ControlSource = "=[Report].[Caption]" .Height = 0.3125 * TwipsPerInch .Width = TwipsPerInch * IIf(IsLandscape, 6, 3.5) .Left = (Rpt.Width / 2) - (.Width / 2) NewTop = .Height End With
Cover image created with Microsoft Designer