When you want to enable your users to print only the records they need, you can set up a form that lets them do just that. For example, to create a form that generates a report listing only the records of employees hired during a specific period, follow these steps:
- In the Database Window, under objects, click Forms, click New, and then click OK. (In Access 2007, click Create and then click the Forms Design command in the Forms group.
- Click the Text box tool in the Toolbar options box. (In Access 2007, click the Text box control on the Design tab.)
- Click and drag to create the first unbound text box. Change the text box label to From:.
- Click the Text Box tool in the Toolbar options box. (In Access 2007, click the Text Box control on the Design tab.)
- Click and drag to create the second unbound text box. Change the text box label to To:.
- Right-click the first text box and select Properties. Click the All tab and then click in the Name property box and type StartDate.
- Right-click the second text box and select Properties. Click the All tab and then click in the Name property box and type EndDate.
- Click the Command tool in the Toolbar Options box. (In Access 2007, click the Command control on the Design tab.)
- Click and drag in the form to locate the Command button. (Click Cancel to close the Command wizard, if necessary.)
- Right-click the Command tool and then click Properties.
- Click the All tab and then click in the Caption property box and type Print Report.
- Click the Event tab.
- Click the Build button in the On Click property box.
- Click Event Procedure.
- Enter the following code at the prompt, as shown in Figure A, and press Alt + Q:
ReportName = "Employees1"
WhereCondition:="[Hire Date] Between #" & _
Me.StartDate & "# AND #" & _Me.EndDate & "#"
To use this form to generate a report for all employees hired from 2001 to 2003, you would enter 1/1/2001 in the From box and 1/1/2003 in the To box (Figure B). Then, just press the Print Report button.
Miss an Access tip?
Check out the Microsoft Access archive and catch up on other Access tips.
Help users increase productivity by automatically signing up for TechRepublic's free Microsoft Office Suite newsletter, featuring Word, Excel, and Access tips, delivered each Wednesday.