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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grid Help

Status
Not open for further replies.

muraliambt

Programmer
Jan 22, 2002
75
US
First time i am developing one-to-many form. what is the best way to develop. Need Advice on this.

* I am using Free Tables for this form *

1. I mean Grid control, creating cursor or use
the table itself in the grid.

2. How to control the no of column display and only the
some field from table not all fields.

3. How to make relations between header and detail table.

4. etc..

Murali.
Programmer
 
The VFP Form Wizard makes a one-to-many form with controls for the parent table and a grid for the child table. I prefer grids for record display myself (FAR easier than coding navigation buttons), so I use 2 grids, but it comes down to preference.

The easiest way to set this up is to create the relation in the form's Data Environment. Add the tables, and drag the related field from the parent table to the child index. For example, if your tables are related on a common field called "cust_num", then scroll through your parent table until you find "cust_num", scroll your child table until you find the index on "cust_num", and drag the parent field "cust_num" to the child index on "cust_num". That will set the relation.

Set your first grid's RecordSource property to the parent table, and the second grid to the child table. Then run the form. As you scroll through the first grid, the second grid should automatically update with the records that match the relation.

To make the grid only show certain columns, use the Grid Builder. Right click on the grid and choose Builder. It's pretty easy to understand. :eek:)

Ian
 
I did the relations same way u said, but child window showing all the records. I have another problem also, i have index in child table with two fields concatenated.

Like this allt(field1)+allt(field2) tag comb1

I linked the two fields form the parent to this index of child. I am getting all records in child.

Muali.
Programmer

 
Ahh...that would be your problem. The Data Environment can only set direct field-to-key relations, it can't do concatenated ones. You will need to set that manually in your form's LOAD or INIT method (should work in either).
Code:
SET ORDER TO combo1 IN ChildTable
SELECT ParentTable
SET RELATION TO ALLTRIM(field1)+;
   ALLTRIM(field2) INTO ChildTable
See how that works for you.
 
How can i include CURSOR into grid and what the code i have to write in which event to display it in the GRID.

Murali.
 
To set the grid's data source to be the child cursor, you would set the grid's RecordSource property to the Alias of the table. Make sure the RecordSourceType is 1-Alias.

From your earlier question I thought you already had this, so I might have misunderstood your question...

Ian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top