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

Setting a grids index

Status
Not open for further replies.

Steve-vfp9user

Programmer
Feb 5, 2013
334
GB
Hello

I have created a form with multiple fields from a table called STOCKBOOK

On that form I have placed a grid (grdExps) which is populated with columns from a table called EXPS

The table's linkmaster is STOCKBOOK and recordsource is EXPS

This works absolutely fine and shows the main record in table STOCKBOOK with any links to the EXPS (expenses) table by a field called STOCKURN.

If I have a single grid on a form, it is easy to issue SET ORDER TO (whatever index tag) but as the grid is a child table (i think that's how you describe it), how do I set the index for the EXPS table grid such as SET ORDER TO EXPDATE DESC

I tried the grids's Childorder in the grids property but that doesn't work and also the grids INIT but that didn't work either.

Any guidance would be very much appreciated.

Thank you

Steve Williams
VFP9, SP2, Windows 10
 
Grid.Linkmaster/Childorder and RelationalExpr triple of properties is not easy to get, but intended for two grids.

If you only show the child data, the parent table is not shown, but its current record will filter the grid. In your case all expenses on the same StockURN.

Well, and that also limits your freedom of setting any other order. As what these grid properties do is exactly the same as a RELATION from parent into child table. And for that to work, the child table has to be ordered by the index that's used by the relation.

What you would need is an index that has both StockURN and Expdate or any other secondary field you'd want to order by. Because there's no way to use two indexes at the same time.

Chriss
 
Chris

I only need to set the order of the linked expenses to EXPDATE DESC when the form is loaded. There is no requirements for any order on the form.

Thank you

Steve Williams
VFP9, SP2, Windows 10
 
The relation or linkmaster only work with an index. And that needs to be on STOCKURN. No matter if you explicitly SET ORDER or use the grid properties.

Chriss
 
Well, that means to get hands on the order you should not use the linkmmaster feature. Instead use SET FILTER TO STOCKURN="xyz", you can also SET KEY "XYZ" , but that again requires the index order to be set to STOCKURN. I'd prefer the simplest solution to get just the data you want to show with SQL: ... where STOCKURN="xyz" ORDER BY EXPDATE DESC.

You could also use a parameterized local view and a parameter for STOCKURN=?m.parameter, set a variable parameter to the STOCKURN and REQUERY('view'). That works nice with a grid.

Chriss
 
I'll look into what you have suggested Chriss

Thank you

Steve Williams
VFP9, SP2, Windows 10
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top