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.
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.
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?