Microsoft KB Archive/207593

= HOW TO: Print Randomly Selected Records in Access 2000 =

Article ID: 207593

Article Last Modified on 6/29/2004

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q207593



Moderate: Requires basic macro, coding, and interoperability skills.

This article applies only to a Microsoft Access database (.mdb).

IN THIS TASK
SUMMARY
 * Add a Yes/No Field to the Table
 * Add a Check Box to a Form
 * Build the Query for the Record Source of the Report
 * Build the Update Query that Resets the Yes/No Field
 * Test the Example

REFERENCES



SUMMARY
This article describes a method that you can use to print records that are randomly selected.

There may be occasions where you need to print a selection of records that do not have a common criteria. For example, you may need to send an acknowledgment to each customer who responded to a survey, but you do not want to keep a permanent record of these responses. To do this, you need to add a Yes/No field to a table, add a check box to a form, and build two new queries. The first query will be a select query that you will use as the record source for the report; the second query will be an update query that you will use to reset the Yes/No field. This example uses the sample database Northwind.mdb.

back to the top

Add a Yes/No Field to the Table
 Open the sample database Northwind.mdb. Select the Customers table, and click Copy on the Edit menu. On the Edit menu, click Paste. In the Table Name text box of the Paste Table As dialog box, type tblExample . Under Paste Options, select Structure And Data, and then click OK.  Open the tblExample table in Design view and add the following field:   Table: tblExample Field Name: ysnPrint Data Type: Yes/No Required: No  Indexed: No                    </li> Save the changes and close the table.</li></ol>

back to the top

Add a Check Box to a Form
<ol> Make a copy of the Customers form as frmExample.</li> Open the frmExample form in Design view.</li>  Change the Caption and RecordSource properties of the form as follows: <pre class="fixed_text">  Form: frmExample -  Caption: Print RecordSource: tblExample </li>  Add the following check box to the form: <pre class="fixed_text">  Check box: ---  Name: chkPrint ControlSource: ysnPrint </li>  Change the Caption property of the adjacent label as follows: <pre class="fixed_text">  Label: -  Name: lblPrint Caption: Print Record </li> Save the changes and close the form.</li></ol>

back to the top

Build the Query for the Record Source of the Report
<ol>  Build the following query: <pre class="fixed_text">  Query: qryExample ---  Type: Select Query

Field: tblExample.* Table: tblExample

Field: ysnPrint Table: tblExample Show: No  Criteria: Yes </li> Make a copy of the Customer Labels report as rptExample.</li> Open the rptExample report in Design view.</li> Change the RecordSource property of the report to qryExample .</li> Save the changes and close the report.</li></ol>

back to the top

Build the Update Query that Resets the Yes/No Field
<ol>  Build the following query: <pre class="fixed_text">  Query: updExample --  Type: Update Query

Field: ysnPrint Table: tblExample Update To: No  Criteria: Yes </li> Save the changes and close the query.</li></ol>

back to the top

Test the Example

 * 1) Open the frmExample form in Form view.
 * 2) Move through the records and, at random, click to select the Print Record check box for a number of records and make a note of those selected.
 * 3) Close the form and open the rptExample report in Print Preview.
 * 4) You should see a mailing label for each of the customers that you selected in Step 2.
 * 5) Close the report and run the qryExample query.
 * 6) Open the frmExample form in Form view and move to each record that you had previously selected in Step 2. Note that the Print Record check box is no longer selected.

back to the top

<div class="references_section">