PC Review


Reply
Thread Tools Rate Thread

Can I use a hierarchical recordset chapter as a subform recordset?

 
 
JR
Guest
Posts: n/a
 
      29th May 2008
I can't seem to find much info at all on this one.. I'd like to to
bind to a disconnected recordset on my parent form and use the chapter
to bind to in the subform. I thought this would acheive automatic
synchronization since navigating through the parent set filters the
chapters accordingly, but the code below simply displays all child
records in the sub form at all times. why doesn't this work? what is
the right way to do this? is the only way to set filters on a chapter
recordset clone for each parent record on the current event?


Private Sub Form_Load()
Dim workRS As New ADODB.Recordset
Dim cnn As New ADODB.Connection

cnn.Provider = "MSDataShape"
cnn.Properties("Data Provider") = "SQLOLEDB"
'...connection info...

cnn.Open
If Not Me.RecordSource = " " Then

workRS.CursorLocation = adUseClient

workRS.Open "SHAPE {select * from tblsite} " _
& "APPEND " _
& "( {SELECT * From tblsitecomponent} RELATE siteid to
siteid ) as components" _
, cnn, adOpenKeyset, adLockBatchOptimistic
workRS.ActiveConnection = Nothing



Set Me.Recordset = workRS

'set subform recordsource
Set Me.Controls("sensors").Form.Recordset = workRS("components").Value

workRS.Close
Set workRS = Nothing
End If
End Sub
 
Reply With Quote
 
 
 
 
JR
Guest
Posts: n/a
 
      29th May 2008


I'm using an access 2003 project connecting to sql server 2005
 
Reply With Quote
 
Paul Shapiro
Guest
Posts: n/a
 
      1st Jun 2008
It's been a long time since I was working with shaped recordsets, but my
memory is that the child recordset contains all the child records, not just
the related child records, even if the parent recordset is filtered to
include a single record. If you only wanted a single parent row, then
filtering the child recordset to return just that one parent's child should
work. If you want multiple parent rows, then I would think that setting the
subform control's Link Master Fields and Link Child Fields property should
provide the correct synchronization. This would be the same settings you'd
use for the subform in a "normal" form-subform situation.

"JR" <(E-Mail Removed)> wrote in message
news:2536a1c9-9783-4210-a1c4-(E-Mail Removed)...
>I can't seem to find much info at all on this one.. I'd like to to
> bind to a disconnected recordset on my parent form and use the chapter
> to bind to in the subform. I thought this would acheive automatic
> synchronization since navigating through the parent set filters the
> chapters accordingly, but the code below simply displays all child
> records in the sub form at all times. why doesn't this work? what is
> the right way to do this? is the only way to set filters on a chapter
> recordset clone for each parent record on the current event?
>
>
> Private Sub Form_Load()
> Dim workRS As New ADODB.Recordset
> Dim cnn As New ADODB.Connection
>
> cnn.Provider = "MSDataShape"
> cnn.Properties("Data Provider") = "SQLOLEDB"
> '...connection info...
>
> cnn.Open
> If Not Me.RecordSource = " " Then
>
> workRS.CursorLocation = adUseClient
>
> workRS.Open "SHAPE {select * from tblsite} " _
> & "APPEND " _
> & "( {SELECT * From tblsitecomponent} RELATE siteid to
> siteid ) as components" _
> , cnn, adOpenKeyset, adLockBatchOptimistic
> workRS.ActiveConnection = Nothing
>
>
>
> Set Me.Recordset = workRS
>
> 'set subform recordsource
> Set Me.Controls("sensors").Form.Recordset = workRS("components").Value
>
> workRS.Close
> Set workRS = Nothing
> End If
> End Sub


 
Reply With Quote
 
JR
Guest
Posts: n/a
 
      3rd Jun 2008
On 1 Jun, 05:43, "Paul Shapiro" <p...@hideme.broadwayData.com> wrote:
> It's been a long time since I was working with shaped recordsets, but my
> memory is that the child recordset contains all the child records, not just
> the related child records, even if the parent recordset is filtered to
> include a single record. If you only wanted a single parent row, then
> filtering the child recordset to return just that one parent's child should
> work. If you want multiple parent rows, then I would think that setting the
> subform control's Link Master Fields and Link Child Fields property should
> provide the correct synchronization. This would be the same settings you'd
> use for the subform in a "normal" form-subform situation.
>
> "JR" <walleniu...@hotmail.com> wrote in message
>
> news:2536a1c9-9783-4210-a1c4-(E-Mail Removed)...
>
>
>
> >I can't seem to find much info at all on this one.. I'd like to to
> > bind to a disconnected recordset on my parent form and use the chapter
> > to bind to in the subform. I thought this would acheive automatic
> > synchronization since navigating through the parent set filters the
> > chapters accordingly, but the code below simply displays all child
> > records in the sub form at all times. why doesn't this work? what is
> > the right way to do this? is the only way to set filters on a chapter
> > recordset clone for each parent record on the *current event?

>
> > Private Sub Form_Load()
> > Dim workRS As New ADODB.Recordset
> > Dim cnn As New ADODB.Connection

>
> > cnn.Provider = "MSDataShape"
> > cnn.Properties("Data Provider") = "SQLOLEDB"
> > '...connection info...

>
> > cnn.Open
> > If Not Me.RecordSource = " " Then

>
> > workRS.CursorLocation = adUseClient

>
> > workRS.Open "SHAPE {select * from tblsite} " _
> > * * * * & "APPEND " _
> > * * * * * & "( {SELECT * From tblsitecomponent} RELATE siteid to
> > siteid ) as components" _
> > * * * * * , cnn, adOpenKeyset, adLockBatchOptimistic
> > workRS.ActiveConnection = Nothing

>
> > Set Me.Recordset = workRS

>
> > 'set subform recordsource
> > Set Me.Controls("sensors").Form.Recordset = workRS("components").Value

>
> > workRS.Close
> > Set workRS = Nothing
> > End If
> > End Sub- Hide quoted text -

>
> - Show quoted text -


Thanks for your response, Paul. but with a bit more research I've
realized the difficulty of working in adp with unbound forms/
disconnected recordsets. Microsoft even explicitly states in a white
paper that it has no elegant solution for that situation (binding
disconnected recordsets to forms). So the only option is complete
coding by hand of unbound forms (or VB or .net I suppose) so, not
surprisingly I took the hint and decided to put the time into
optimizing performance with an immediate connection. not such a bad
thing i suppose, but it would have been great to grab needed records
at the beginning, unplug, edit, plug in and batch update.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Acc 2007 Subform Recordset vs Acc 2002 Subform Recordset dbqph Microsoft Access Form Coding 2 3rd Feb 2010 06:19 AM
Binding a form to a disconnected recordset and making it capable to update such recordset Yarik Microsoft Access 2 22nd Nov 2006 02:18 AM
CopyFromRecordset will fail if the recordset array data such as hierarchical recordsets ??? Mike Microsoft Excel Programming 0 10th Jun 2006 03:05 PM
Access 2002: bind adodb recordset to listbox recordset property Craig Buchanan Microsoft Access Form Coding 2 1st May 2005 12:14 AM
Filtering on a Hierarchical recordset =?Utf-8?B?UFN3YW5pa2Vy?= Microsoft ADO .NET 0 28th Apr 2005 08:43 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:41 PM.