main logo
Subject: Re: navigating in parent of table one to many form
Author: "Rafael Copquin"
Posted: 2007/08/31 12:46:55
 
View Entire Thread
New Search


In cases like this, I would do away with a relation and simply use select sql, as in this example

use table1 in 0 shared && parent
use table2 in 0 shared && child

**Assumption: parent primary key is codeid and child foreign key is codeid
** parent table is an invoice header and child table is invoice details

method navigate

local nCodeId

thisform.grid1.recordsource = '' && your invoice details (table2 data) go here through the cursor in the select below

select table1

nCodeId = table1.codeid

select * from table2 where codeid = nCodeId into cursor curDetails readwrite nofilter

thisform.grid1.recordsource = "curDetails"
thisform.refresh

** navigation buttons

every time you move down, up, to top or to bottom, you should do so in the parent table

example, move to the next record in btnNext

select table1
if not eof('table1')
skip
if eof('table1')
go bottom
endif
else
go bottom
endif
thisform.navigate()

With the above approach, every time you hit the corresponding navigation button, a call is made to the navgate method on the form, the grid recordsource is temporarily set to nothing, so when you run your select it does not change it's settings

You then run your select and populate the grid again and refresh the form

You don't have in this manner any problems with relations, avoid the problem you described and, in addition, since you are using a select statement, your datasource could even be SqlServer, MySql, VFP, etc

regards

Rafael Copquin


----- Original Message -----
From: Tracy Pearson
To: profoxtech /AT/ leafe .D.O.T com
Sent: Friday, August 31, 2007 8:39 AM
Subject: Re: navigating in parent of table one to many form


The parent table has a SET SKIP TO set to the child table.
I'm not sure if this is the right way to go about it, or if you just need
to turn it off. It depends on what your form is supposed to be doing.

Select Parent
Set Skip To
Skip
Set Skip To Child
ThisForm.Refresh()

HTH,
Tracy

On Fri, August 31, 2007 6:34 am, Steven Holt wrote:
> I'm suspect, I'm making a very simple error in form navigation but have
> just not figured out a way past it.
>
> I've been trying without success to make a set of navigation buttons to
> navigate the parent table in a VFP 6 wizard generated one to many form.
> I've tried to put roughly these pared down pieces below of code into a
> new set of next/previous buttons in the click event method.
>
> select parent
> skip
> thisform.refresh
>
> and
>
> skip in parent
> thisform.refresh
>
> When anything happens at all, it only moves in the child table not the
> parent until the end of the many children is reached in the child table
> and only then does the parent increment. I've tried moving control onto
> the parent by selecting it in the screen's data environment and clearly
> I just don't know how to control these silly forms. They are powerful,
> but tend to be a bit opaque at times for what should be a painfully
> simple modification. I suspect I may not be successfully refreshing
> the data buffering with the refresh.
>
> Best,
>
> Steve





[excessive quoting removed by server]


 
©2007 Rafael Copquin
<-- Prior Message New Search Next Message -->