Share via


Display Child Records from a Relationship Sample

File: ...\Samples\Solution\Controls\Grid\1_many.scx

This sample demonstrates coordinating a one-to-many form with two grids displaying the many sides of the relationships. Very little code is needed in this sample. Setting a few properties is all that is involved.

Property Settings

Text boxes for the "one" side of the relationship:

ControlSource = Customer.cust_id
ControlSource = Customer.company

Grid for the first "many" side of the relationship:

ChildOrder = cust_id
LinkMaster = customer
RecordSource = orders
RecordSourceType = 1 - Alias
RelationalExpr = customer.cust_id
ColumnCount = 4
   Column1.ControlSource = "orders.order_no"
   Column1.Header1.Caption = "Order"
   Column2.ControlSource = "orders.order_date"
   Column2.Header1.Caption = "Date"
   Column3.ControlSource = "orders.to_name"
   Column3.Header1.Caption = "Ship To"
   Column4.ControlSource = "orders.order_amt"
   Column4.Sparse = .F.
   Column4.Header1.Caption = "Total"
   Column4.Text1.InputMask = "$$999,999.99"

Grid for the 2nd "many" side of the relationship:

ChildOrder = order_id
LinkMaster = Orders
RecordSource = Orditems
RecordSourceType = 1 - Alias
RelationalExpr =Orders.order_id
ColumnCount = 4
   Column1.ControlSource = "orditems.line_no"
   Column1.Header1.Caption = "Item"
   Column2.ControlSource = "products.prod_name"
   Column2.Header1.Caption = "Product"
   Column3.ControlSource = "orditems.quantity"
   Column3.Header1.Caption = "Qty."
   Column4.ControlSource = "orditems.unit_price"
   Column4.Sparse = .F.
   Column4.Header1.Caption = "Price"
   Column4.Text1.InputMask = "$$9,999.99"

In addition to the text boxes and the grids, the form contains an object based on the VCR class in Buttons.vcx. The SkipTable property of this class is set to the table you want the record pointer to be moved in when the user chooses a table navigation button. Because the user can easily manually move through the records in the grids (Orders and Orditems), SkipTable is set to Customer.

See Also

Tasks

Display Calculated Values in a Column Sample

Display Controls in a Grid Sample

Dynamically Format Grid Columns Sample

Other Resources

Controls Solution Samples