ACC2000: How to Print Randomly Selected Records
ID: Q207593
|
The information in this article applies to:
Moderate: Requires basic macro, coding, and interoperability skills.
This article applies only to a Microsoft Access database (.mdb).
SUMMARY
This article describes a method that you can use to print records that are
randomly selected.
MORE INFORMATION
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.
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
- Save the changes and close the table.
Add a Check Box to a Form
- Make a copy of the Customers form as frmExample.
- Open the frmExample form in Design view.
- Change the Caption and RecordSource properties of the form as follows:
Form: frmExample
-------------------------
Caption: Print
RecordSource: tblExample
- Add the following check box to the form:
Check box:
-----------------------
Name: chkPrint
ControlSource: ysnPrint
- Change the Caption property of the adjacent label as follows:
Label:
---------------------
Name: lblPrint
Caption: Print Record
- Save the changes and close the form.
Build the Query for the Record Source of the Report
- Build the following query:
Query: qryExample
-------------------
Type: Select Query
Field: tblExample.*
Table: tblExample
Field: ysnPrint
Table: tblExample
Show: No
Criteria: Yes
- Make a copy of the Customer Labels report as rptExample.
- Open the rptExample report in Design view.
- Change the RecordSource property of the report to
qryExample.
- Save the changes and close the report.
Build the Update Query that Resets the Yes/No Field
- Build the following query:
Query: updExample
------------------
Type: Update Query
Field: ysnPrint
Table: tblExample
Update To: No
Criteria: Yes
- Save the changes and close the query.
Test the Example
- Open the frmExample form in Form view.
- 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.
- Close the form and open the rptExample report in Print Preview.
- You should see a mailing label for each of the customers that you
selected in Step 2.
- Close the report and run the qryExample query.
- 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.
REFERENCES
For more information about update queries, click Microsoft Access Help on the
Help menu, type "update queries, creating" in the Office Assistant or the Answer Wizard,
and then click Search to view the topics returned.
For more information about creating check boxes, click Microsoft Access Help on the
Help menu, type "check boxes, creating" in the Office Assistant or the Answer Wizard,
and then click Search to view the topics returned.
Additional query words:
limit inf
Keywords : kbprint kbdta GnlOthr
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbhowto