Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VFP9 Setting Up a One-to-Many Form Using the Grid Control 2

Status
Not open for further replies.

Steve-vfp9user

Programmer
Feb 5, 2013
337
GB
Hello

I have created a form with two grids and cant get the child records linked to show against the adult record.

One grid contains data from the SUPPLIER table and the second grid contains data from SUPITEMS table. The tables are linked on the form in the data environment via an index field called PURNLINK.

When I run the form there is no issue showing the SUPPLIER records as I scroll through but the linked SUPITEMS records to the SUPPLIERS record are not showing.

I found several links for example and but these appear to be deal with fields on a form from one table and a grid whereas I have two grids. I cant use the wizard because that doesn't give me two grids (and I would rather have a go myself).

Can you suggest what I may be doing wrong please?

Thank you

Steve
 
Steve, it's difficult to know without seeing what you have already done. But off the top of my head:

- Set the child grid's Linkmaster to the alias of the parent.

- Set the child grid's RelationalExpr to the field (or expression) in the parent that defines the relationship.

You say you prefer not to use the Wizard. Quite right. But have you considered using the Builder? Right-click on the child grid (in the form designer), choose Builder, and then go to the Relationships tab.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Hi Steve,

You may want to add the following code
Code:
ThisForm.YourChildGrid.Refresh()
into the "Parent's" grid AfterRowColChange
hth
MK
 
Mike
[ul]
[li]I set the child grid's Linkmaster to the alias of the parent table (SUPPLIER)[/li]
[li]I then set the child grid's RelationalExpr to the field (PURNLINK) in the parent table that defines the relationship[/li]
[li]I then used the builder by right-clicking the child grid and setting the "Related index in child table: " to PURNLINK[/li]
[/ul]

This has resolved my issue and the correct linked child records are showing against the adult record as I scroll through the adult grid.

Thank you!

MK

In the grids AfterRowColChange I already have: Thisform.grdPlnkjbps.Refresh (thank you also)

Appreciate your efforts guys.

Thank you

Steve
 
Glad to hear you've got it working, Steve.

For the record, I didn't mean you to do both those things (setting the properties AND using the Builder). The point is that the Builder provides an alternative way of setting the properties. (But you've probably realised this now.)

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top