ACC2000: Error with Subform Based on Hierarchical ADO Recordset
ID: Q199113
|
The information in this article applies to:
Advanced: Requires expert coding, interoperability, and multiuser skills.
This article applies to a Microsoft Access database (.mdb) and a Microsoft Access project (.adp).
SYMPTOMS
When you use the MSDatashape provider to create a hierarchical recordset, and you then assign the recordset to a subform, you may receive the following error message:
Run-time error '2147417848(80010108)':
Method 'Recordset' of object '_Form_<form name>' failed
STATUS
Microsoft has confirmed this to be a problem in the Microsoft products listed
at the beginning of this article.
MORE INFORMATION
Microsoft Access 2000 exposes a new Recordset property for forms through which you can assign a recordset to a form. ActiveX Data Objects (ADO) allows you to create hierarchical, or chaptered, recordsets where each row in a recordset contains a recordset with related child records (such as the subdatasheets in tables).
Steps to Reproduce Problem
- Create a new database in Access called TestDB.mdb.
- On the File menu, point to Get External Data, and then click Link Tables.
- Browse to the sample database Northwind.mdb, select it, and click Link.
- In the Link Tables dialog box, select the Categories and Products tables. Click OK.
- In TestDB.mdb, click Forms under Objects, and then click Create form by using Wizard.
- Select the Categories table and include all the fields. Click Finish.
- View the new Categories form in Design view.
- Click the Subform/Subreport button in the toolbox and draw a subform on the Categories form.
NOTE: In order to draw the subform, you may need to resize the Categories form.
- In the SubForm Wizard, click Next on the first screen.
- On the second screen, select the Products table and include all fields. Click Finish.
- Add the following code to the Open event of the Categories main form.
NOTE: The sample code in this article uses Microsoft ActiveX Data Objects. For this code
to run properly, you need to reference the Microsoft ActiveX Data Objects 2.1 Library.
NOTE: The following code assumes the Northwind sample database is installed in its default location on drive C. If this is different on your installation, please change the path accordingly.
Sub Form_Open(Cancel As Integer)
Dim cn As New ADODB.Connection
Dim rsCategories As New ADODB.Recordset
Dim rsProducts As ADODB.Recordset
Dim strSQL As String
cn.Provider = "MSDataShape"
cn.Open "DATA PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE = " & _
"C:\Program Files\Microsoft Office\Office\Samples\Northwind.mdb"
strSQL = "SHAPE {SELECT * FROM Categories} APPEND " & _
"({SELECT * FROM Products} As rsProducts RELATE CategoryID TO " & _
"CategoryID)"
rsCategories.Open strSQL, cn, adOpenKeyset, adLockOptimistic
Set Me.Recordset = rsCategories
Set rsProducts = rsCategories("rsProducts").Value
Set Me![Products Subform].Form.Recordset = rsProducts
End Sub
- Save the form and close it.
- Open the form in Form view. Note that you receive the following error:
Run-time error '2147417848(80010108)':
Method 'Recordset' of object '_Form_Products subform' failed.
Additional query words:
pra chapter shape
Keywords : kberrmsg kbdta AccessCS
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbbug