ACC2000: No CanShrink Property for Check Boxes (209490)
The information in this article applies to:
This article was previously published under Q209490 Moderate: Requires basic macro, coding, and interoperability skills.
This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).
SYMPTOMS
There is no CanShrink property for check boxes or option buttons on a form or report.
RESOLUTION
The following workaround demonstrates a method that uses a text box to
simulate a check box on a report. You can set the CanShrink property
of the text box to Yes, and if the text box is not selected, it
shrinks and is not printed.
To create a "check box" style control that is not printed if it is blank, follow these steps: CAUTION: If you follow the steps in this example, you modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and follow these steps on a copy of the database. - Start Microsoft Access, and then open the sample database Northwind.mdb or the sample project NorthwindCS.adp.
- In the Database window, click Reports, and then click New. In the New Report dialog box, click Design View, and then select Products as the table where the object's data comes from.
- Drag the ProductName and Discontinued fields from the Products field list into the Details section of the report, and then place the Discontinued field to the right of the ProductName field, on the same line, near the top of the section.
- Add a text box with a label to the Details section and assign the following properties:
Text Box
Name: txtDisconCheckBox
Control Source: =IIf([Discontinued]=-1,"X")
Can Shrink: Yes
Border Style: Solid
Border Width: 1 pt
Text Align: Center
Width: .166"
Height: .166"
Label
Name: lblCheckBox
Caption: Shrink Discontinued
Place the txtDisconCheckBox text box and lblCheckBox label below the ProductName field. - Set the properties for the report's Detail section as follows:
Can Shrink: Yes
On Format: ShrinkNo
- Save the report as rptDiscontinued.
- In the Database window, click Macros, and then click New. On the View menu, click Conditions. Create the following macro and save it as ShrinkNo:
Condition Action Action Arguments
----------------------------------------------------------
[Discontinued]=-1 SetValue Item: [lblCheckBox].Visible
Expression: True
[Discontinued]=0 SetValue Item: [lblCheckBox].Visible
Expression: False
- Preview the rptDiscontinued report.
Notice that there is a text box containing an "X" only for the records that have a check in the Discontinued field. The txtDisconCheckBox text box for the other records is not visible and is not printed.NOTE: The txtDisconCheckBox text box shrinks if it is the only item sharing the same horizontal plane on the report. Do not overlap the text box with any other control positioned to the left or right of it. The ShrinkNo macro hides the lblCheckBox label for the text box when the Discontinued field is blank, which allows the text box and the Detail section to shrink.
REFERENCESFor more information about the CanShrink Property, click Microsoft Access Help on the Help menu, type cangrow, canshrink properties in the Office Assistant or the Answer Wizard, and then click Search to view the topic.
Modification Type: | Minor | Last Reviewed: | 7/15/2004 |
---|
Keywords: | kbprb KB209490 |
---|
|