Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to navigate the child Recordset ?

Status
Not open for further replies.

Suwito

Programmer
Apr 24, 2001
16
0
0
ID
I create a Master/Detail Form with 2 levels of view (parent, child grid) and below is the code to do so using a shape command.

Code:
SHAPE {select * from SALES_H) AS ParentCMD APPEND ({select * from SALES_D } AS ChildCMD RELATE RefNo TO RefNo) AS ChildCMD

How to navigate (MoveNext, MovePrevious, MoveFirst, MoveLast) the child Recordset in Data Shapes.

Help please.........
Thank's
 
Here's a code snippet I found:
===============================================================================
Code:
    Dim objConn     As New ADODB.Connection
    Dim objRec      As New ADODB.Recordset
    Dim objCmd      As New ADODB.Command
    Dim objRec2     As New ADODB.Recordset
    
    Dim objRecTitle As ADODB.Recordset
    Dim strShape    As String
    
    ' use the data shape provider,
    ' with SQL Server as the source of the data
    objConn.Provider = "MSDataShape"
    objConn.Open m_sConn
    
    ' define our shape string and open the recordset
    ' - this requires the
    strShape = "SHAPE {{CALL dbo.usp_PublishersByCountry('USA') }} AS PubsByCountry" & _
        " APPEND ({{CALL dbo.usp_TitlesByPubID( ?) }} AS TitlesByPubID" & _
        " RELATE pub_id TO  PARAMETER 0) AS TitlesByPubID"
        
    Set objCmd.ActiveConnection = objConn
    objCmd.CommandText = strShape
    objCmd.Parameters.Append objCmd.CreateParameter("@Country", _
                                    adVarChar, adParamInput, 30, "USA")
    objCmd.Parameters.Append objCmd.CreateParameter("@@PubID", _
                                    adInteger, adParamInput)
    
    Set objRec = objCmd.Execute
    
    ' loop through the parent records
    While Not objRec.EOF
        Debug.Print objRec("pub_name")
    
        ' set the recordset for the child
        ' records and loop through them
        Set objRecTitle = objRec("TitlesByPubID").Value
        While Not objRecTitle.EOF
            Debug.Print vbTab; objRecTitle("title")
            objRecTitle.MoveNext
        Wend
        objRec.MoveNext
    Wend

Good Luck!
-Mats Hulten
 
I have tried and that clearing my problem.


Thank's MatsHulten
 
Do you have any simple sample code which uses Master/Detail/Sub Details.

Help will br really appreciated...Athar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top