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!

VFP7: Parent/Child(s) with SKIP TO (NON WIZARD)

Status
Not open for further replies.

cj001

Programmer
Oct 3, 2001
145
US
Hello!

I have 3 tables. 1 Parent and 2 Childern (no grids).

All 3 tables have the same key field.

I have a navigation buttons which advance the parent just fine, but I want the navigation buttons also advance the children.

How do I do this?

Thanks!
CJ
 
Take a look at SET RELATION TO in the help file.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Thank you for your response Mike Gagnon.

I have looked at it, but it shows 1 parent to 1 child relationship (what I consider a 1 to 1 relationship). It indicates that 1 parent to many children can be set, but it doesn't give an example. So when I try it it doesn't work. I'm obviously not doing something correctly. This is why I need and example of an actual one to many relationship.


CJ
 
cj001

Here is a "quick" example how it works:
Code:
PUBLIC oform1
oform1=NEWOBJECT("form1")
oform1.Show
RETURN
DEFINE CLASS form1 AS form
	DoCreate = .T.
	Caption = "Form1"
	Name = "Form1"
	ADD OBJECT text1 AS textbox WITH ;
		ControlSource = "parent.name", ;
		Height = 25, ;
		Left = 84, ;
		Top = 12, ;
		Width = 121, ;
		Name = "Text1"
	ADD OBJECT text2 AS textbox WITH ;
		ControlSource = "child1.address", ;
		Height = 25, ;
		Left = 48, ;
		Top = 72, ;
		Width = 121, ;
		Name = "Text2"
	ADD OBJECT command1 AS commandbutton WITH ;
		Top = 192, ;
		Left = 132, ;
		Height = 27, ;
		Width = 84, ;
		Caption = "Command1", ;
		Name = "Command1"
	ADD OBJECT text3 AS textbox WITH ;
		ControlSource = "child2.street", ;
		Height = 23, ;
		Left = 204, ;
		Top = 72, ;
		Width = 100, ;
		Name = "Text3"
	ADD OBJECT label1 AS label WITH ;
		Caption = "Parent", ;
		Height = 17, ;
		Left = 228, ;
		Top = 12, ;
		Width = 40, ;
		Name = "Label1"
	ADD OBJECT label2 AS label WITH ;
		Caption = "Child1", ;
		Height = 17, ;
		Left = 72, ;
		Top = 48, ;
		Width = 40, ;
		Name = "Label2"
	ADD OBJECT label3 AS label WITH ;
		Caption = "Child2", ;
		Height = 17, ;
		Left = 216, ;
		Top = 48, ;
		Width = 40, ;
		Name = "Label3"
	PROCEDURE Load
		CREATE CURSOR parent (syskey c(10),name c(20))
		INSERT INTO parent (syskey,name) VALUES ("1","Mike")
		INSERT INTO parent (syskey,name) VALUES ("2","Paul")
		INSERT INTO parent (syskey,name) VALUES ("3","Frank")
		SELECT parent
		INDEX ON syskey TAG sysparent
		GO top
		CREATE CURSOR child2 (syskey c(10),street c(10))
		INSERT INTO child2 (syskey, street) VALUES ("1","nowhere")
		INSERT INTO child2 (syskey, street) VALUES ("2","somewhere")
		INSERT INTO child2 (syskey, street) VALUES ("3","here")
		INDEX ON syskey TAG sysChild2
		CREATE CURSOR child1 (syskey c(10),address c(10))
		INSERT INTO child1 (syskey, address) VALUES ("1","123")
		INSERT INTO child1 (syskey, address) VALUES ("2","532")
		INSERT INTO child1 (syskey, address) VALUES ("3","531")
		INDEX ON syskey TAG sysChild1
		SELECT parent
		SET RELATION TO parent.syskey INTO child1,parent.syskey INTO child2
		SET SKIP TO child1
		SET SKIP TO child2
	ENDPROC
	PROCEDURE command1.Click
		SELECT parent 
		SKIP
		thisform.Refresh()
	ENDPROC
ENDDEFINE


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Thanks Mike Gagnon. It is becoming clearer now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top