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