Hello,
I have created a datreport using a dataenvironment and a parent / child commant.
My parent command is cmdHeader and child is cmdDetail. My report works well so far, but I need to be able to change the sql statement in my cmdHeader command.
I think I have succesfully figured out how to change the sql statement, but now I am getting "Datafield 'cmdDetail.REREAS' not found".

I am still pretty new to vb, so you may have to speak slowly.

In searching for this I have ran across issues of having to requery after changing the sql statement, so may code may have some unneeded lines in there all in an attemt to fix the issue.

Please help, I am running out of hairs to pull out.

Code:
Private Sub cmdGo_Click()

Dim strSQL As String

strSQL = "SELECT AID, APN, AWO, ASEQ, EMNAME, AINSPDAT, SUM( NFAILQTY ) AS ""SumNfailqty"", PMDESC, ISECNP " & _
    "From NCM.NCM001P1 NCM001P1, NCM.NCM002P1 NCM002P1, HFADTA160.PM PM, HFADTA160.""IS"" TIS, HFADTA160.EM EM " & _
    "Where NCM001P1.AID = NCM002P1.NAID AND NCM001P1.APN = PM.PMPART AND PM.PMPART = TIS.ISPART AND NCM001P1.AINSPBY = EM.EMKEY " & _
    "Group By AID, APN, AWO, ASEQ, EMNAME, AINSPDAT, PMDESC, ISECNP"

deCT.Commands("cmdHeader").CommandText = strSQL

'Rebind After Using Requery Method

'close if open
If deCT.rscmdHeader.State = adStateOpen Then
deCT.rscmdHeader.Close
End If

deCT.rscmdHeader.Open
deCT.rscmdHeader.Requery

With rptCautionTag
   Set .DataSource = deCT
   .DataMember = "cmdHeader"
   .Sections("Detail").Controls.Item("txtREREAS").DataMember = "cmdDetail"
   .Sections("Detail").Controls.Item("txtREREAS").DataField = ("REREAS")
   
End With

    
    rptCautionTag.Orientation = rptOrientLandscape
    rptCautionTag.Show 1