Microsoft KB Archive/174002

= ACC: Can't Enable Pages Option Button in CommonDialog Control =

Article ID: 174002

Article Last Modified on 1/20/2007

-

APPLIES TO


 * Microsoft Access 97 Standard Edition
 * Microsoft Office 97 Developer Edition

-



This article was previously published under Q174002



Advanced: Requires expert coding, interoperability, and multiuser skills.



SYMPTOMS
The Pages option button of the CommonDialog ActiveX control remains disabled when you set the Flags property to the cdlPDPageNums constant.



RESOLUTION
You must set the Max property of the CommonDialog control to a value greater than 0, and greater than the value of the control's Min property. To enable the Pages option button, follow these steps:

 Follow steps 1 through 6 of the "Steps to Reproduce" Section later in this article.  Set the command button's OnClick property to the following event procedure:

Private Sub Command1_Click Dim cd As CommonDialog Set cd = Me!CmnDlg.Object With cd           .Flags = cdlPDPageNums

' Allow a page range of 1 - 50 to be entered in           ' the dialog box. .Min = 1 .Max = 50

' Default the From box to 1, and the To box to 50. ' Note that the FromPage property must be greater than or           ' equal to the Min property, and the ToPage property ' must be less than or equal to the Max property. .FromPage = 1 .ToPage = 50 .ShowPrinter End With End Sub  Open the form in Form view. Click the command button.

Note that the Pages option button and associated edit controls are enabled, and the page range is set from 1 to 50 by default.



MORE INFORMATION
The Flags property of the CommonDialog control allows you to specify the cdlPDPageNums constant to enable the Pages option button and associated edit controls. However, because the default value for both the Min and Max properties of the CommonDialog control is 0, the user cannot enter a valid page range in the From and To boxes. Therefore, your code must automatically set the Max property to a value greater than the Min property.

Steps to Reproduce Behavior
 Open the sample database Northwind.mdb.</li> Open a new, blank form in Design view.</li> On the Insert menu, click ActiveX Control.</li> Select Microsoft Common Dialog Control, version 5.0, and then click OK.</li> Set the Name property of the CommonDialog control to "CmnDlg."</li> Add a command button to the form.</li>  Set the command button's OnClick property to the following event procedure:

Private Sub Command1_Click Dim cd As CommonDialog Set cd = Me!CmnDlg.Object ' Enable Pages option button. cd.Flags = cdlPDPageNums cd.ShowPrinter End Sub </li> Open the form in Form view.</li> Click the command button.

Note that the Pages option button and associated edit controls are disabled, even though the Flags property is set to the cdlPDPageNums constant.</li></ol>

<div class="references_section">