Using ParentDataSource to Tie Detail with Header Issue

SOLVED

Hi all,

I hope someone will be able to help me with this issue. I currently have a form that has a FEC that displays and controls the PO number, and then a AccpacViewlist that displays some of the details for that PO (e.g. Exp Arrival Date, item number, etc...). I have two AccpacDataSource, one for the header called dsPOPORH, and the other for the detail called dsPOPORL. I am able to activate dsPOPORH, but when it comes to activating dsPOPORL, it gives me the error "Error activating Sage Accpac datasource". Here is a snippet of the code I am trying to run:

With mDBLinkCmpRW
.OpenViewInstance "PO0620", ckPTPORH, True
.OpenViewInstance "PO0630", ckPTPORL, True
End With

'Activate DataSource
With dsPTPORH
.ViewID = "PO0620"
.DBLinkCompany = mDBLinkCmpRW
.AutoCompose = False
.Active = True
.Order = 1
.Browse "PORTYPE = 1 AND ISCOMPLETE = FALSE AND (STATUS = 10 OR STATUS = 70 OR STATUS = 90) AND RCPCOUNT = 0", True
End With

With dsPTPORL
.DBLinkCompany = mDBLinkCmpRW
.ParentDataSource = dsPTPORH
.ViewID = "PO0630"
.AutoCompose = False
.Active = True
.Order = 1
End With

It's basically just erroring out during the active = true in the dsPOPORL. I need the detail to refresh as users flip through the POs, which is why I am setting the parent datasource. Does anyone have experience with using ParentDataSource or AccpacViewList?

Any help or advice would be greatly appreciated.

  • 0
    verified answer

    Just for anyone who might want to know in the future. I managed to solve this issue by using this snippet of code:

    ' Set session/activate Order Headers Data Source

    dsPOPORH.Session = AccpacSession

    dsPOPORH.ViewID = "PO0620"

    dsPOPORH.Order = 1

    dsPOPORH.Active = True

    dsPOPORH.Browse "", True

    ' Set session/activate Order Details Data Source, setting

    ' the ParentDataSource to Order Headers (using that Session)

    dsPOPORL.Session = AccpacSession

    dsPOPORL.ParentDataSource = Me.dsPOPORH

    dsPOPORL.ViewID = "PO0630"

    dsPOPORL.Active = True

    I had been previously using this code to connect the dsPOPORL to dsPOPORH, but was having issues when typing in the PO number in the FieldEdit Control (it would always cancel after typing and tabbing out of the field, and the field would not update).

    I found that the "dsPOPORH.Order = 1" and "dsPOPORH.Browse "", True" was imperative to get this working properly.