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!

Cyclic Relation

Status
Not open for further replies.

David Higgs

Programmer
May 6, 2012
390
GB

The following code works ok:-

Code:
SELECT B
USE WAB_books order callsign ALIAS Books

SELECT C
USE wab_members_award order callsign ALIAS Members

SET RELATION TO callsign INTO B

and the following code produces a "cyclic relation" error.

Code:
*SELECT B
USE WAB_books IN 0 order callsign ALIAS Books

*SELECT C
USE wab_members_award IN 0 order callsign ALIAS Members

SET RELATION TO callsign INTO Books

I don't understand why!


Regards,
David
 
Because when you [tt]USE <a table> IN 0[/tt], it doesn't change to that table's work area. Wheichever work area was selected before will still be selected.

So if Books happened to be the selected area before the snippet of code that you showed, it will still be the selected area, hence the cyclic relationship.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Hello Mike,

Thank you for your reply.

I was just doing a bit of tidying up one of my applications and getting away from an old habit of using Work Area Letters. I can see now that previously I was selecting the work area before opening the DBF and that in using Work Area "IN 0" I need to "Select" the area before setting the relation. Having done that, all is now working ok.






Regards,
David
 
A way to solve that in a comnpatible way is SELECT 0 instead of SELECT A/B/C or 1/2/3 etc. Simply always SELECT 0
Then you first use an empty workarea and the table you open is selected.

Bye, Olaf.
 
Another way to do this. Reverse the order of opening:

Code:
Select 0
USE wan_members_award order callsign ALIAS Members
USE WAB_books IN 0 order callsign ALIAS Books
* members is currently selected
SET RELATION TO callsign INTO Books

This would actually take advantage of the behavior that initially tripped you up. But note the comment I added pointing out the subtlety to anyone reading the code later.

When I'm editing "legacy" (I'm being kind) code, a lot of times my first pass will be just adding comments that point out what's currently selected. And it often takes considerable study.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top