Results 1 to 6 of 6

Thread: Data Shaping Problem

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2007
    Posts
    4

    Data Shaping Problem

    Ok, the scnenario is that, I'm creating a pay slip using VB6 Data Report Designer and MS Data Shape. For each employee, there will be some employee details like Emp. ID, Name, Department which is concealed in a parent recordset. This parent recordset has two child recordsets, one to hold renumeration paycodes with respective amounts and the other one holds deduction paycodes, with respective amounts as well. The code is like this:

    Code:
        Dim arrEmp()    As String
        Dim arrRen()    As String
        Dim arrDed()    As String
        Dim arrVal()    As String
        Dim empid       As String
        Dim i2          As Integer
        Dim rsRenumeration  As ADODB.Recordset
        Dim rsDeduction     As ADODB.Recordset
        
        
        arrEmp = GetEmployeeSlipList
        If UBound(arrEmp) = 0 Then
            MsgBox "No employee record found.", vbOKOnly + vbExclamation, "Notification"
            cmdClose.SetFocus
            Exit Sub
        End If
        
        sShape = "SHAPE APPEND NEW adInteger AS emp_id, NEW adVarChar(200) AS emp_name, NEW adVarChar(200) AS group_name, NEW adDate AS paydate," _
             & " ((SHAPE APPEND NEW adInteger AS emp_id, NEW adVarChar(200) AS paycode_name, NEW adDouble AS total_amount) AS rsRenumeration RELATE emp_id TO emp_id)," _
             & " ((SHAPE APPEND NEW adInteger AS emp_id, NEW adVarChar(200) AS paycode_name, NEW adDouble AS total_amount) AS rsDeduction RELATE emp_id TO emp_id)"
        
        Set SRS = New ADODB.Recordset
        With SRS
            .Open sShape, sConn, adOpenStatic, adLockOptimistic, -1
            For I = 0 To UBound(arrEmp) - 1
                arrVal = Split(arrEmp(I), "!@", , vbTextCompare)
                .AddNew
                    !emp_id = arrVal(0)
                    !emp_name = arrVal(1)
                    !group_name = arrVal(2)
                    !payDate = Format(CDate(arrVal(3)), "dd/MM/yyyy")
                .Update
                empid = arrVal(0)
                
                arrRen = GetSlipPaycodes(empid, 0)      '0 for addition paycodes
                Set rsRenumeration = .Fields("rsRenumeration").value
                With rsRenumeration
                    For i2 = 0 To UBound(arrRen) - 1
                        arrVal = Split(arrRen(i2), "!@", , vbTextCompare)
                        .AddNew
                        !emp_id = empid
                        !paycode_name = arrVal(0)
                        !total_amount = CDbl(arrVal(1))
                        .Update
                    Next i2
                End With
                
                arrDed = GetSlipPaycodes(empid, 1)      '1 for deduction paycodes
                Set rsDeduction = .Fields("rsDeduction").value
                With rsDeduction
                    For i2 = 0 To UBound(arrDed) - 1
                        arrVal = Split(arrDed(i2), "!@", , vbTextCompare)
                        .AddNew
                        !emp_id = empid
                        !paycode_name = arrVal(0)
                        !total_amount = CDbl(arrVal(1))
                        .Update
                    Next i2
                End With
            Next I
        End With
        
        With DataRep_PaySlip_Frame
            Set .DataSource = SRS
            .DataMember = SRS.DataMember
            DoEvents
            .Show
        End With
    My problem arises when it comes to this lines:
    Code:
        With DataRep_PaySlip_Frame
            Set .DataSource = SRS
            .DataMember = SRS.DataMember
            DoEvents
            .Show
        End With
    I've got an error telling that "DataField rsRenumeration.paycode_name not found."
    I thick there is no problem on data insertion I made before those lines but who knows. Can anyone help me solve this? Because I think this suppose to be an easy report only.
    Last edited by lee san; Nov 15th, 2007 at 02:46 AM.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Data Shaping Problem

    Moved to Reporting

  3. #3
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Data Shaping Problem

    Did you set the DataMember property of the controls bound to the child recordsets?

    The DataMember property should be set to rsRenumeration and the DataField property set to paycode_name.

  4. #4

    Thread Starter
    New Member
    Join Date
    Nov 2007
    Posts
    4

    Re: Data Shaping Problem

    Yes I did. I set DataMember= rsRenumeration and DataField=paycode_name.
    I have no problem with recordset which has 3 stage of relationship, meaning parent, child, grandchild.

  5. #5
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Data Shaping Problem

    I have no problem with recordset which has 3 stage of relationship, meaning parent, child, grandchild.
    You have a Parent Child Child relationship, I am not sure if that is supported by the DataReport. Does the report have one or more Groups. Can you post the datareport file?

  6. #6

    Thread Starter
    New Member
    Join Date
    Nov 2007
    Posts
    4

    Re: Data Shaping Problem

    aTTACHMENT IS THE dATA rEPORT FILE. sORRY FOR LATE REPLY..
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width