Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

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

↑ Back to the top


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.

↑ Back to the top


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.

↑ Back to the top


Status

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

↑ Back to the top


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.

↑ Back to the top


Keywords: KB257696, kbdapscript, kbdap, kbbug

↑ Back to the top

Article Info
Article ID : 257696
Revision : 2
Created on : 6/24/2004
Published on : 6/24/2004
Exists online : False
Views : 241