February 19, 2009

Create an Access form that lets users specify which data to print

  • Date: October 28th, 2008
  • Author: Mary Ann Richardson

You can easily add a custom form button that enables your users to choose which records to print. Mary Ann Richards steps through the process.


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:

  1. 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.
  1. Click the Text box tool in the Toolbar options box. (In Access 2007, click the Text box control on the Design tab.)
  1. Click and drag to create the first unbound text box. Change the text box label to From:.
  1. Click the Text Box tool in the Toolbar options box. (In Access 2007, click the Text Box control on the Design tab.)
  1. Click and drag to create the second unbound text box. Change the text box label to To:.
  1. Right-click the first text box and select Properties. Click the All tab and then click in the Name property box and type StartDate.
  1. Right-click the second text box and select Properties. Click the All tab and then click in the Name property box and type EndDate.
  1. Click the Command tool in the Toolbar Options box. (In Access 2007, click the Command control on the Design tab.)
  1. Click and drag in the form to locate cialis soft the Command button. (Click Cancel to close the Command wizard, if necessary.)
  1. Right-click the Command tool and then click Properties.
  1. Click the All tab and then click in the Caption property box and type Print Report.
  1. Click the Event tab.
  1. Click the Build button in the On Click property box.
  1. Click Event Procedure.
  1. Enter the following code at the prompt, as shown in Figure A, and press Alt + Q:

Dim ReportName   ReportName = "Employees1"   DoCmd.OpenReport _   ReportName:=ReportName, _   view:=acViewPreview, _   WhereCondition:="[Hire Date] Between #" & _   Me.StartDate & "# AND #" & _   Me.EndDate & "#"

Figure A

custom button code

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.

Figure B

print report

Permalink • Print • Comment

Leave a comment

You must be logged in to post a comment.

Made with WordPress and a healthy dose of Semiologic • Sky Gold skin by Denis de Bernardy