Microsoft KB Archive/257696

= ACC2000: Option Group Based on Yes/No or Bit Field on Data Access Page Is Not Displayed Correctly =

Article ID: 257696

Article Last Modified on 6/24/2004

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q257696



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

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).



SYMPTOMS
When you create an option group on a data access page, and you bind the option group to a Yes/No or to a Bit field, the option buttons in that group do not display any values even though the option group is correctly bound to the page source. However, if you click either the Yes or the No option button in that option group, the underlying value in the table is changed to the value that you selected in the option group.



RESOLUTION
To work around this behavior, follow these steps:  Open the sample database Northwind.mdb. In the Database window, click Pages under Objects, and then click New. In the New Data Access Page dialog box, click Design View. If the field list is not displayed, click Field List on the View menu. Drag the following fields from the Products table from the field list to the 2-D design section of the page:  ProductID</li> ProductName</li> Discontinued</li></ul> </li> Click the Option Group button in the toolbox, and then drag the button to the design section of the page.</li>  Change the following properties of the option group: <pre class="fixed_text">  ID: MyOptionGroup </li> Add two option buttons inside the option group frame.</li>  Change the properties of the first option button as follows: <pre class="fixed_text">  ID: MyYesOption Value: -1 </li>  Change the properties of the second option button as follows: <pre class="fixed_text">  ID: MyNoOption Value: 0 </li> On the Tools menu, point to Macro, and then click Microsoft Script Editor.</li> By default, there are three panes presented in the Microsoft Script Editor. In the pane on the left, click the Scripts tab.</li> Browse through the editor to the following event: Client Objects and Events\MSODSC\Current</li>  Place the following between the Script tags: Document.All.Item("MyYesOption").Checked=False Document.All.Item("MyNoOption").Checked=False

If MSODSC.DefaultRecordset.Fields.Item("Discontinued") = False Then Document.All.Item("MyNoOption").Checked = True Document.All.Item("MyYesOption").Checked = False Else Document.All.Item("MyYesOption").Checked = True Document.All.Item("MyNoOption").Checked = False End If                   </li>  Change the initial Script tag from: <SCRIPT event=Current for=MSODSC language=vbscript> to <SCRIPT event=Current(abc) for=MSODSC language=vbscript> </li> Browse through the editor to the following event: Client Objects and Events\MyYesOption\onclick</li>  Place the following between the Script tags: MSODSC.DefaultRecordset.Fields("Discontinued") = -1 Document.All.Item("MyYesOption").Checked = True Document.All.Item("MyNoOption").Checked = False </li> Browse through the Script Editor to the following event: Client Objects and Events\MyNoOption\onclick</li>  Place the following between the Script tags: MSODSC.DefaultRecordset.Fields("Discontinued") = 0 Document.All.Item("MyYesOption").Checked = False Document.All.Item("MyNoOption").Checked = True </li> <li>On the File menu, click Save.</li> <li>On the File menu, click Exit to exit the Microsoft Script Editor.</li> <li>On the View menu, click Page View. Note that the option group based on the Yes/No field now works as expected.</li></ol>

<div class="status_section">

STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

<div class="moreinformation_section">

Steps to Reproduce the Behavior
<ol> <li>Open the sample database Northwind.mdb.</li> <li>In the Database window, click Pages under Objects, and then click New.</li> <li>In the New Data Access Page dialog box, click Design View.</li> <li>If the field list is not displayed, click Field List on the View menu.</li> <li>Drag the following fields from the Products table from the field list to the 2-D design section of the page: <ul> <li>ProductID</li> <li>ProductName</li> <li>Discontinued</li></ul> </li> <li>Click the Option Group button in the toolbox, and then drag the button to the design section of the page.</li> <li> Change the following properties of the option group: <pre class="fixed_text">  ID: MyOptionGroup ControlSource: Discontinued </li> <li>Add two option buttons inside the option group frame.</li> <li> Change the properties of the first option button as follows: <pre class="fixed_text">  ID: MyYesOption Value: -1 </li> <li> Change the properties of the second option button as follows: <pre class="fixed_text">  ID: MyNoOption Value: 0 </li> <li>On the View menu, click Page View.

Note that as you scroll through the records on this page, the Discontinued check box changes appropriately for each record in the Products table, but the option group never displays an option for Yes or No.</li></ol>

Additional query words: pra

Keywords: kbbug kbdap kbdapscript KB257696

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.