Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parent/Child Relationships in Grid

Status
Not open for further replies.

MaryG

Programmer
Mar 26, 2001
26
AU
Hi,
Can anyone help me with this one please? I have looked through previous threads and MS Help but I am missing something. I am new to Visual FoxPro so bear with me please.

I have a form that displays details from cont_det(parent). A grid displays budget details from bud_ob (child). This is set up using properties RecordSource,LinkMaster,ChildOrder, etc and works fine.

bud_ob has a lookup table fd_list:
fd_list.fund_idno = bud_ob.fund_idno

I am trying to display Fd_list.value in a column on the grid, using bud_ob.fund_idno to get a value from fd_list. Fd_list.value is correct in the first row but the other rows contain the same value - not their own values from fd_list. I have checked and fund_idno is correct for each row but it is as if it is not being used properly to populate each row with fd_list.value.

I have tried SET RELATION in the init of both the column and the grid to join bud_ob and fd_list.
I have tried using a SELECT
Code:
SELECT fd_list
  LOCATE for fund_idno = bud_ob.fund_idno

But no luck. How do I get the column to display values from a lookup properly?

Thank You
Mary


 
I am not highly skilled at it, but it sounds to me like you are pushing it a bit. I get around such problems by creating a consolidated file in two steps. Views no doubt are workable, but I tend to fall back on rude and crude when there's probably ample power there, but it can get really tricky. I will normally only work with a portion of my database at once, so an extra step once at the start and once at the finish doesn't make a lot of difference.

When you open the form, the parent workspace is active, but it seems to me that right off the top the child is accessable only for the last record. To access more of the children, you need to switch to the child's workspace, but reaching a third work area from that gets messier and probably requires a programming step. That's where I would put the programming relation into an additional file like a view (though I tend to make it a temporary real datafile without automatically updating the masters) and then form the parent child form with that as the child.

A view used in a similar fashion would probably not be to hard to use, but I shy away from endangering my large primary files with too many SQL's from my much smaller work files, so I can't offer anymore experience there. My file structures are a bit complex, and always seem to want to get worse.

Hey, I tried. :)
 
1. The SET RELATION might have been given by you in the reverse. You can specify the relationship in the DE.

Select bud_ob
SET RELATION TO fund_idno INTO Fd_list
LOCATE

2. There is a possibility, that you are Selecting the fd_list and locating the record after the relations are set. This could create an error situation. Seeking, Locating etc in the firing events of the grid will not fetch all the matching records in a Grid.

Building a view may be a good idea... but traps do exist.. just in case the resulting DBF is empty and grid shows up not the way you want.
ramani :)
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top