Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grids and Grandchildren
Message
From
13/04/2002 06:19:12
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
12/04/2002 17:12:28
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00644553
Message ID:
00644658
Views:
9
>Ok,
>
>Hopefully this will be simple for someone to answer.
>
>I have a Parent - Child - Grandchild table structure. Table1 is the parent, Table2 is the Child, Table3 is the Grandchild. I have a relation between Table1 and Table2 (SET RELATION TO table1_key INTO table2 IN table1). There is a grid on my form that displays Table3 and has all of the appropriate properties set up correctly (childorder, linkmaster, etc.) to make Table3 a child of Table2. However, the grid will not display only the records appropriate for Table2. If, after running the form, I select table2 and browse it, the grid updates and now displays the correct records. If I remove Table1 from the mix and make Table2 my top level table, the grid works correctly. If I make the grid display the info for Table2 instead of Table3, it works correctly. The only time I can't get it to display correctly is when all three tables are involved. I have even opened all tables from the command window and manually set the relations, and browsed the tables, and everything is fine (move
>the record pointer in Table1 and Tables 2 and 3 update correctly).
>
>What am I missing here?

Brian,
Probably you used DE to setup tables and sounds like it's an "InitialAlias' problem. Try setting 'InitialAlias' to Table1. Also be sure you didn't set any order to something that would break the relationship.

Actually with ChildOrder,LinkMaster, RelationalExpr settings you don't need to set any relation. ie :
oForm = createobject('GrandChild')
oForm.Show
Read events

Define class GrandChild as Form
  Height = 600
  Width = 800
  DataSession = 2

  Procedure load
    Use customer in 0
    Use orders in 0
    Use orditems in 0
  Endproc

  Procedure init
    With this
      .AddObject('grdCustomer','Grid')
      .AddObject('grdOrders','Grid')
      .AddObject('grdOrdItems','Grid')
      With .grdCustomer
        .Columncount=-1
        .RecordSource = 'Customer'
        .Top = 0
        .Left = 0
        .Height = 190
        .Width = 800
      Endwith
      With .grdOrders
        .Columncount=-1
        .RecordSource = 'Orders'
        .LinkMaster = 'Customer'
        .ChildOrder = 'cust_id'
        .RelationalExpr = 'cust_id'
        .Top = 200
        .Left = 0
        .Height = 190
        .Width = 800
      Endwith
      With .grdOrdItems
        .Columncount=-1
        .RecordSource = 'OrdItems'
        .LinkMaster = 'Orders'
        .ChildOrder = 'order_id'
        .RelationalExpr = 'order_id'
        .Top = 400
        .Left = 0
        .Height = 190
        .Width = 800
      Endwith
      .SetAll('Visible',.t.)
    Endwith
  Endproc
  Procedure queryunload
    Clear events
  Endproc
Enddefine
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform