Dyamic Data View

Is there a way to dynamically change the parent child relationship to a foreignkey view?  I have a UD table that is linked to MFG jobs one way (UD20.Key1 = JobHead.JobNum) and needs to link on the same screen to PRJ / WBS phase jobs another way (UD20.Key1 ~= (select JobHead.JobNum from JobHead where JobHead.ProjectID = thisrow's.ProjectID and JobHead.PhaseID = (thisrow's PhaseID + "mfg")).   The records are displayed in an UltraGrid based on the UD20View and the user can add records.

I am having issues determining where to start with this.  I have the MFG portion working.  Does anyone have any insight or examples they'd be willing to share?

Thanks in advance,