Home arrow Articles arrow Paradox Programming arrow Simulating Data Model Links via Filters
07 September 2010
 
 
Simulating Data Model Links via Filters PDF Print E-mail
Contributed by Roy Frieband   
28 March 2002
Got unkeyed tales? Need to "link" them together on a form? Roy shows us a quick and easy technique to link together unkeyed tables to simulate a master-detail relationship.Simulating Data Model Links via Filters
© 2002 Roy Frieband

Introduction

There may be circumstances when you want or have to create several unkeyed tables from code in the private directory or have to deal with multiple unkeyed tables for whatever reason. Using the following simple technique, you can simulate a data model link between the unkeyed tables that is fast and effective.


Example

For this example assume you have 4 unkeyed tables in the private directory. The table you want to use as the "master" in the simulated data model should have a unique integer field. Let's call this table ":PRIV:Mastertbl.db" and the unique integer field "ID". Let's call the other 3 tables ":PRIV:Detail1.db", ":PRIV:Detail2.db", ":PRIV:Detail3.db". Each of these tables should also have a nonunique integer field also called "ID" that corresponds to the "ID" field in the "master table".

Also for this example let's put tableframes on a form bound to each table. The tableframes are named Mastertf, Detail1tf, Detail2tf, Detail3tf to correspond to the above tables.

This code goes in the arrive method of the record object in the Mastertf tableframe:
var
  id              LongInt
  dyn             DynArray[]  String
  stField, stData String
endvar

dmGet("MASTERTABLE","ID",id)

stField = "ID"
stData = String(id)
dyn[stField] = stData

Detail1tf.setGenFilter(dyn)
Detail2tf.setGenFilter(dyn)
Detail3tf.setGenFilter(dyn)
Detail1tf.home()
Detail2tf.home()
Detail3tf.home()
The above code allows you to scroll through the Mastertf tableframe and the detail tableframes will change just as if they were linked to the master in the datamodel.
< Prev   Next >
 
Top! Top!