Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Multi-tabled /Parent-Child/Related forms
Message
From
03/03/2000 04:42:23
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00340832
Message ID:
00341131
Views:
15
>Between all of these I am prob just confused with their diffrences
>but all I am trying to do is create a form that has it's own data
>and also has data that is updateable and linked to 4 other tables.
>
>So basicly you enter the id of a customer in the .....................Anitable
>and the Linked field with his name comes up..........................Customer Table
>and the linked fields with his Phone#'s comes up....................PhoneNumber Table
>and the linked fields with his TollFree#'s comes up..................TollFree Table
>and the linked fields with his Calling Card#'s comes up............Calling Card Table
>
>Also you enter his site # and then it pulls in the Site name from the Site Table.
>
>I have done this same thing is Access, and Advanced Revelation
>but can not seem go understand how to do so in VFP
>Right Now I just have the tables added to the form via DE and dropped 2 fields
>on to the form to create the grid. I then right clicked on the grid and used the builder
>to modi the grid to just a single field and set it up like i needed. I repeated this
>step 2 more time to complete the form. everything works sorta ok but the grids
>do not update properly.
>
>Mike D.


Mike,
It's doable in fox in "at least" 3 ways. I'll take one that has roots since foxbase days (I won't be dealing with persistent relations at all).

Every table would have a ParentId (or FK) and its own Id (or PK) fields (even topmost parent could have a dummy ParentId field). Suppose you simply use 10 char field for IDs that's generated by sys(2015).

Anitable :
ParentId 10 C
Id 10 C (default : sys(2015) )

CustomerTable :
ParentId 10 C (default : iif(used("AniTable"),AniTable.Id,sys(2015)) )
Id 10 C (default : sys(2015) )

And so on for other tables. Each ParentId and Id fields would be indexed.
Now put them all in form DE. Except the topmost parent, set every tables order property to "ParentId".
-Drop field(s) from Anitable on form
-Select a few fields from each of remaining tables to create grids
-Select grids and set properties :
ChildOrder = "ParentId" && Order of child
RelationalExpression = "Id" && Parent expression that links to child
AllowAddNew = .T. && Just for a quickstart - other than that I do not use
-Then select them one by one and set property linkmaster (Parent Table) :
For Customer table
LinkMaster = "AniTable" && ParentTable

One step left is "refresh" for grids. For the moment go "AfterRowColChange" of each grid and code :

thisform.Child1.refresh
thisform.Child2.refresh
...

Where Child1, Child2 ... refers to Child grid names for that particular grid. AniTable Id field change could simply call "thisform.refresh".
I don't know if this is more complex than Access or not but works consistently and fast.
PS: Again I don't intend this should be the way how to do it. This is just a simple quickstart way.
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