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



The information in this article applies to:

  • Microsoft Access 2000

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:
  1. Open the sample database Northwind.mdb.
  2. In the Database window, click Pages under Objects, and then click New.
  3. In the New Data Access Page dialog box, click Design View.
  4. If the field list is not displayed, click Field List on the View menu.
  5. Drag the following fields from the Products table from the field list to the 2-D design section of the page:
    • ProductID
    • ProductName
    • Discontinued
  6. Click the Option Group button in the toolbox, and then drag the button to the design section of the page.
  7. Change the following properties of the option group:
       ID: MyOptionGroup
    					
  8. Add two option buttons inside the option group frame.
  9. Change the properties of the first option button as follows:
       ID: MyYesOption
       Value: -1
    					
  10. Change the properties of the second option button as follows:
       ID: MyNoOption
       Value: 0
    					
  11. On the Tools menu, point to Macro, and then click Microsoft Script Editor.
  12. By default, there are three panes presented in the Microsoft Script Editor. In the pane on the left, click the Scripts tab.
  13. Browse through the editor to the following event: Client Objects and Events\MSODSC\Current
  14. 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
    					
  15. Change the initial Script tag from:
    <SCRIPT event=Current for=MSODSC language=vbscript>
    					
    to
    <SCRIPT event=Current(abc) for=MSODSC language=vbscript>
    					
  16. Browse through the editor to the following event: Client Objects and Events\MyYesOption\onclick
  17. Place the following between the Script tags:
    MSODSC.DefaultRecordset.Fields("Discontinued") = -1
    Document.All.Item("MyYesOption").Checked = True
    Document.All.Item("MyNoOption").Checked = False
    					
  18. Browse through the Script Editor to the following event: Client Objects and Events\MyNoOption\onclick
  19. Place the following between the Script tags:
    MSODSC.DefaultRecordset.Fields("Discontinued") = 0
    Document.All.Item("MyYesOption").Checked = False
    Document.All.Item("MyNoOption").Checked = True
    					
  20. On the File menu, click Save.
  21. On the File menu, click Exit to exit the Microsoft Script Editor.
  22. On the View menu, click Page View. Note that the option group based on the Yes/No field now works as expected.

STATUS

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

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Open the sample database Northwind.mdb.
  2. In the Database window, click Pages under Objects, and then click New.
  3. In the New Data Access Page dialog box, click Design View.
  4. If the field list is not displayed, click Field List on the View menu.
  5. Drag the following fields from the Products table from the field list to the 2-D design section of the page:
    • ProductID
    • ProductName
    • Discontinued
  6. Click the Option Group button in the toolbox, and then drag the button to the design section of the page.
  7. Change the following properties of the option group:
       ID: MyOptionGroup   
       ControlSource: Discontinued
    					
  8. Add two option buttons inside the option group frame.
  9. Change the properties of the first option button as follows:
       ID: MyYesOption
       Value: -1
    					
  10. Change the properties of the second option button as follows:
       ID: MyNoOption
       Value: 0
    					
  11. 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.

Modification Type:MajorLast Reviewed:6/24/2004
Keywords:kbbug kbDAP kbDAPScript KB257696