Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Update vs. insert
Message
From
30/07/2001 16:53:14
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00537366
Message ID:
00537471
Views:
12
>Nancy,
>
>I think while SQL commands are executing thisform can sometimes no longer in scope as far as VFP is concerned. I've had to make sure that object properties are not used for view parameters, they need to be copied to local memvars before issuing a Requery().

I'd buy that except that thisform.someproperty works okay.
PUBLIC oform1

oform1=NEWOBJECT("form1")
oform1.Show
RETURN


	**************************************************
*-- Form:         form1 (g:\poe_vfp6\poe\tables\temp.scx)
*-- ParentClass:  form
*-- BaseClass:    form
*-- Time Stamp:   07/30/01 01:03:09 PM
*
DEFINE CLASS form1 AS form


	Top = 0
	Left = 0
	Height = 115
	Width = 181
	DoCreate = .T.
	Caption = "Form1"
	cvalue = "NewValue"
	Name = "Form1"


	ADD OBJECT command1 AS commandbutton WITH ;
		Top = 70, ;
		Left = 5, ;
		Height = 20, ;
		Width = 88, ;
		Caption = "SQL - UPDATE", ;
		Name = "Command1"


	ADD OBJECT text1 AS textbox WITH ;
		Value = "Value To Set Field To...", ;
		ControlSource = "thisform.cValue", ;
		Height = 23, ;
		Left = 4, ;
		Top = 4, ;
		Width = 154, ;
		Name = "Text1"


	ADD OBJECT command2 AS commandbutton WITH ;
		Top = 92, ;
		Left = 5, ;
		Height = 20, ;
		Width = 88, ;
		Caption = "INSERT INTO", ;
		Name = "Command2"


	ADD OBJECT command3 AS commandbutton WITH ;
		Top = 82, ;
		Left = 96, ;
		Height = 20, ;
		Width = 62, ;
		Caption = "BROWSE", ;
		Name = "Command3"


	ADD OBJECT text2 AS textbox WITH ;
		Alignment = 3, ;
		Value = 2, ;
		Height = 23, ;
		Left = 160, ;
		Top = 4, ;
		Width = 19, ;
		Name = "Text2"


	PROCEDURE Load
		CREATE TABLE TEMP (C1 C(25), N1 I)
		INSERT INTO TEMP (C1, N1) VALUES ("Hello", 1)
		INSERT INTO TEMP (C1, N1) VALUES ("GoodBye", 2)
		INSERT INTO TEMP (C1, N1) VALUES ("So long", 3)
		INSERT INTO TEMP (C1, N1) VALUES ("Adios", 4)
		INSERT INTO TEMP (C1, N1) VALUES ("Greetings!", 5)
	ENDPROC


	PROCEDURE command1.Error
		LPARAMETERS nError, cMethod, nLine
		MESSAGEBOX( "Error in SQL-UPDATE!: " + MESSAGE() )
		RETURN
	ENDPROC


	PROCEDURE command1.Click
		UPDATE TEMP SET C1 = THISFORM.Text1.VALUE WHERE N1 = 2 && This line will cause an error.
		*!*	UPDATE TEMP SET C1 = THIS.PARENT.Text1.VALUE WHERE N1 = 2 && This line will cause an error.
		*!*	UPDATE TEMP SET C1 = EVALUATE("THIS.PARENT.Text1.VALUE") WHERE N1 = 2 && This line will cause an error.
		*!*	UPDATE TEMP SET C1 = THISFORM.cValue WHERE N1 = 2 && This line will not cause an error.
		*!*	UPDATE TEMP SET C1 =  EVALUATE("THIS.PARENT.Text1.VALUE") WHERE N1 = THISFORM.Text2.VALUE && This line will cause an error.
		*!*	UPDATE TEMP SET C1 = THISFORM.cValue WHERE N1 = THISFORM.Text2.VALUE && This line will not cause an error.
	ENDPROC


	PROCEDURE command2.Click
		INSERT INTO TEMP (C1, N1) VALUES (Thisform.Text1.Value, RECCOUNT() + 1 )
	ENDPROC


	PROCEDURE command3.Click
		BROWSE
	ENDPROC


ENDDEFINE
*
*-- EndDefine: form1
**************************************************
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform