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

set relation problem

Status
Not open for further replies.

LindaRichard

Programmer
Feb 23, 2001
103
CA
Hi,

I have a form that contains the tables rockfile and gsc_age in the data environment. In the load event of this form I create a view called tmp_rock which includes fields only from rockfile. Here is an example SQL

CREATE SQL VIEW tmp_rock AS SELECT DISTINCT r.* from rockfile r, gsc_age a
where a.age > 1500 and r.prov='ON'
and r.labno=a.labno

The tmp_rock view is then displayed in a grid.

I want to print in a report the tmp_rock and gsc_age information for one record
So I am trying to set the relation between tmp_rock and gsc_age. For one tmp_rock
record there can be many gsc_age.

Here is my code

*make sure the table is seleted
select tmp_rock
*set a relationship between tmp_rock and gsc_age
set relation to labno into gsc_age
*set the relation to one to many
set skip to gsc_age
*----------------------------------------------------------------
*preview the report
*----------------------------------------------------------------
*user has selected to preview one sample
REPORT FORM rockfrm for tmp_rock.labno=ThisForm.pfrock.Page1.txtLabno.value PREVIEW
*----------------------------------------------------------------
*clear the table relationship
*----------------------------------------------------------------
*select the table
select tmp_rock
*clear the relationship
set relation to
*clear the one to many
set skip to

My problem is that I keep getting the following error message
gsc_age is not related to the current work area.

Any ideas what I am doing wrong.

Thanks
Linda


 
Linda,
It's not obvious from your code, but do you have the table gsc_age's index currently set to the field that is equivalent to labno?

I'm also curious why you don't order the view?

Rick

 
Does reversing the order of the execution of SET SKIP TO and SET RELATION TO eliminate the problem? It would seem that the SET RELATION TO command has already broken the relationship and clearing the SKIP may be either redundant or "confusing".
 
Thanks to both of you for your help,

Changing the order of the two statements SET SKIP... did not make a difference.

However, setting the order to labno in gsc_age did. I already had the order in tmp_rock set to labno but setting the order of gsc_age in the data environment
seems to have fixed the problem.

I am not sure why setting the order in the data environment fixed the problem, but
it does seem to work now.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top