Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Need Grid to Show All Child Records that Match Parent Ke
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 8
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01073370
Message ID:
01073382
Views:
39
>I am trying to get a grid to show each child record that matches the key in the parent table. I put 3 records (1,2,3) into the parent table, and 4 (a,b,c,d) into the child table. If it were working properly, picking record 2 from the parent would show child records b and d in the grid. Instead, what is happening is that 4 rows appear; all of the columns to which I assigned a ControlSource are showing record b's data, and the columns without a ControlSource are showing data for each record (a,b,c,d).
>
>In other words, instead of:
>b,b,b,b,b (Row matching data in record b)
>d,d,d,d,d (Row matching data in record d)
>
>I'm getting:
>b,b,a,b,a
>b,b,b,b,b
>b,b,c,b,c
>b,b,d,b,d (Four rows, with a hodgepodge of record b and the sequential row)
>
> I have tinkered with LinkMaster, ChildOrder, and RelationalExpr. I have tried SET KEY TO, REFRESH(), SET SKIP TO, and moving the record pointer. I have set up the relation in the LOAD, INIT, and ACTIVATE methods (not all at once), and in a new method that I created.
> Right now, my code is:
>
>*Init method
>SELECT child
>SET ORDER TO childindex
>SELECT Parent
>SET RELATION TO parentkey INTO child
>SEEK tuParm1 &&Parameter passed from previous form
>
>All of the other relevant properties are default.
>How do I fix this problem?

try this:
SELECT Parent
SEEK tuParm1 &&Parameter passed from previous form
SELECT child
SET ORDER TO childindex
SET KEY TO Parent.ParentKey
*** Refresh the grid
But I would use parametrised CursorAdadpter or LocalView based on Child.
Something like:
** CA SelectCmd
TEXT TO this.SelectCmd NOSHOW
     SELECT * FROM Child WHERE ParentKey == ?m.lnParentKey
ENDTEXT

*** Or View Definition:
     SELECT (full field list don't use *) FROM Child WHERE ParentKey == ?m.lnParentKey
Then just
SELECT Parent
SEEK tuParm1 &&Parameter passed from previous form
m.lnParentKey = Parent.ParentKey
REQUERY("MyChildCAorView")
*** Refresh the grid
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform