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

Last reviewed: September 19, 1997
Article ID: Q174002
The information in this article applies to:
  • Microsoft Access 97
  • Microsoft Office Developer Edition 97

SYMPTOMS

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

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:

  1. Follow steps 1 - 6 of the "Steps to Reproduce" Section later in this article.

  2. 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
    
    

  3. Open the form in Form view.

  4. 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

  1. Open the sample database Northwind.mdb.

  2. Open a new, blank form in Design view.

  3. On the Insert menu, click ActiveX Control.

  4. Select Microsoft Common Dialog Control, version 5.0, and then click OK.

  5. Set the Name property of the CommonDialog control to "CmnDlg."

  6. Add a command button to the form.

  7. 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
    
    

  8. Open the form in Form view.

  9. 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.

REFERENCES

For more information about the Common Dialog control, search the Help Index for "CommonDialog control," or ask the Microsoft Access 97 Office Assistant.

For more information about using the Max property with the Common Dialog control, search for "Max property," and then "Max, Min Properties (CommonDialog)" using the Help Index.


Additional query words: prb custom
Keywords : OdeGen IntpCstm
Technology : ole
Version : WINDOWS:97
Platform : WINDOWS
Hardware : x86
Issue type : kbprb
Solution Type : kbworkaround


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 19, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.