Hi,

In vb i used data form wizard to create Master/Details form from a database. When i run that code i get a error in the below line:

Private Sub Form_Load()
Set grdDataGrid.DataSource = datPrimaryRS.Recordset("ChildCMD").UnderlyingValue
End Sub

It says Data error event hit err:[ADODC]: Unknown error. [ADO] then it says
Runtime error '91'
Object Variable or With block Variable not set.

But when i use Northwind database it doesnot give me error and its working fine.

Can somebody help me on this please.

Krs

Dani AI

Generated

A short, practical diagnosis and fix for VB6 Data Form Wizard master/detail failures.

The wizard often generates code that relies on ADO’s Data Shaping service (SHAPE) to produce a parent recordset with a chapter (child) column. That chapter column holds a child Recordset object rather than a simple scalar; if the code accesses the wrong Field property or the shaping provider/connection isn’t available, the grid bind will fail with object-not-set errors. (learn.microsoft.com)

Most common, fast fix: retrieve the child Recordset from the chapter Field’s Value (not its UnderlyingValue) and bind that Recordset to the grid. Example (VB6 + ADO):

Dim cn As ADODB.Connection
Dim rsParent As ADODB.Recordset
Dim rsChild As ADODB.Recordset

Set cn = New ADODB.Connection
cn.Open "Provider=MSDataShape;Data Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Path\MyDb.mdb;"

Set rsParent = New ADODB.Recordset
rsParent.Open "SHAPE {SELECT ...} APPEND ({SELECT ...} AS ChildCMD RELATE ParentID TO ChildParentID)", cn

Set rsChild = rsParent.Fields("ChildCMD").Value   ' Value returns the child Recordset
Set MSFlexGrid1.DataSource = rsChild

The docs show that a chapter field’s Value property yields the child Recordset; UnderlyingValue is documented for the field’s stored database value and is not the right binding for a chapter/child Recordset. Also verify the shaping/provider stack is present: use MSDataShape with an appropriate data provider (Jet 4.0 for legacy MDBs; ACE for ACCDB), confirm MDAC/Data Shaping DLLs are installed, and ensure the parent recordset is open/positioned before grabbing the child. (learn.microsoft.com)

Because replies in this thread (for example , and ) touched on both environment and reference issues, start with these steps: try the .Value approach above; check the connection string/provider and MDAC installation; confirm the ADO library reference in the VB6 project; and if shaping is unavailable or brittle on target machines, implement master/detail with explicit parent/child queries instead of relying on MSDataShape (the shaping service is an older feature and not recommended for new work). (learn.microsoft.com)

Recommended Answers

All 3 Replies

An invalid variable is being referenced. To create an object variable, declare the object variable and then assign a valid reference to the object variable using the Set statement. Similarly, a With...End With block must be initialized by executing the With statement entry point.


1.Make sure the object variable references a valid object, and specify or respecify a reference for the object.
2.Make sure you did not use an object variable set to Nothing.
3.Make sure the object library in which the object has been described has been selected in the Add References dialog box.
4.Make sure your With block is initialized by executing the With statement entry point.

Hi,

I have solved the issue. Its nothing Vb6 doesnot support access 2000/2003 database. When i convert it to 97 it worked fine.

VB6 actually do support access 2000/2003. Your problem was with the data control. If you have however solved this, please mark it as solved, thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.