Microsoft Access 2010 Bible

(Rick Simeone) #1

Part III: More-Advanced Access Techniques


738


The inset in the lower-right part of Figure 20.29 shows the information provided by adding the
four text boxes to this report. Very often, the user is not even aware of the name of a report — the
only text the user sees associated with reports is the text that appears in the title bar (in other
words, the report’s Caption property). If a user is having problems with a report, it might be
helpful to display the information you see in Figure 20.29 in the report footer.

Adding the user’s name to a bound report
An unbound text box with its ControlSource set to an unresolved reference will cause Access
to pop up a dialog box requesting the information necessary to complete the text box. For exam-
ple, an unbound text box with its RecordSource set to the following displays the dialog box you
see in the middle of Figure 20.30 when the report is run:

=[What is your name?]

Access displays a similar Parameter dialog box for each parameter in a parameter query. The text
entered into the text box is then displayed on the report. (rptUserName in Chapter20.accdb
on this book’s companion CD-ROM demonstrates this technique.)

FIGURE 20.30

Use an unbound text box to capture useful information.


The unbound text box on the report can be referenced by other controls on the report. The
Parameter dialog box appears before the report is prepared for printing, which means that the data
you enter into the dialog box can be used in expressions, calculations, or the VBA code behind the
report.

Cross-Reference
Chapter 27 describes the GetUserNameA Windows API call. This function returns the user’s Windows login
name and is the ideal way to capture the name of the person printing an Access report.

Free download pdf