Microsoft KB Archive/310569

= PRB: Using Object.Value in UPDATE - SQL Fails =

Article ID: 310569

Article Last Modified on 5/12/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition
 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 5.0a
 * Microsoft Visual FoxPro 6.0 Professional Edition
 * Microsoft Visual FoxPro 7.0 Professional Edition

-



This article was previously published under Q310569



SYMPTOMS
When you use an Object.Object.Value reference in an UPDATE - SQL command, you may receive the following error message:

Alias 'object' is not found.

This error occurs only if the Object.Object.Value syntax appears on the right side of the assignment in the SET clause.



RESOLUTION
To work around this problem, you can find other ways to use the object value. The sample code in the &quot;More Information&quot; section shows some possibilities.



Steps to Reproduce Behavior
  Run the following code: PUBLIC ofrmUpdate

ofrmUpdate=createOBJECT(&quot;frmUpdate&quot;) ofrmUpdate.Show RETURN

DEFINE CLASS frmUpdate AS form

Top = 0 Left = 0 Height = 115 Width = 181 DoCreate = .T.  Caption = &quot;Update Form&quot; cValue = &quot;NewValue&quot; Name = &quot;frmUpdate&quot;

ADD OBJECT cmdUpdate AS commandbutton WITH ; Top = 70, ; Left = 5, ; Height = 20, ; Width = 88, ; Caption = &quot;UPDATE - SQL&quot;, ; Name = &quot;cmdUpdate&quot;

ADD OBJECT txtValue AS textbox WITH ; Value = &quot;Value To Set Field To...&quot;, ; ControlSource = &quot;ThisForm.cValue&quot;, ; Height = 23, ; Left = 4, ; Top = 4, ; Width = 154, ; Name = &quot;txtValue&quot;

ADD OBJECT cmdInsert AS commandbutton WITH ; Top = 92, ; Left = 5, ; Height = 20, ; Width = 88, ; Caption = &quot;INSERT INTO&quot;, ; Name = &quot;cmdInsert&quot;

ADD OBJECT cmdBrowse AS commandbutton WITH ; Top = 82, ; Left = 96, ; Height = 20, ; Width = 62, ; Caption = &quot;BROWSE&quot;, ; Name = &quot;cmdBrowse&quot;

ADD OBJECT txtKey AS textbox WITH ; Alignment = 3, ; Value = 2, ; Height = 23, ; Left = 160, ; Top = 4, ; Width = 19, ; Name = &quot;txtKey&quot;

PROCEDURE Load CREATE TABLE tblUpdate (cField1 C(25), iField1 I)     INSERT INTO tblUpdate VALUES (&quot;Hello&quot;, 1) INSERT INTO tblUpdate VALUES (&quot;GoodBye&quot;, 2) INSERT INTO tblUpdate VALUES (&quot;So long&quot;, 3) INSERT INTO tblUpdate VALUES (&quot;Adios&quot;, 4) INSERT INTO tblUpdate VALUES (&quot;Greetings!&quot;, 5) ENDPROC

PROCEDURE cmdUpdate.Click *!* The following lines will cause the error. UPDATE tblUpdate ; SET cField1 = ThisForm.txtValue.VALUE ; WHERE iField1 = 2 *!* UPDATE tblUpdate ; SET cField1 = THIS.PARENT.txtValue.VALUE ; WHERE iField1 = 2

*!* The following lines will not cause the error. *!* UPDATE tblUpdate ; SET cField1 = EVALUATE(&quot;THIS.PARENT.txtValue.VALUE&quot;) ; WHERE iField1 = 2 *!* UPDATE tblUpdate ; SET cField1 = ThisForm.cValue ; WHERE iField1 = 2 *!* UPDATE tblUpdate ; SET cField1 = EVALUATE(&quot;THIS.PARENT.txtValue.VALUE&quot;) ; WHERE iField1 = ThisForm.txtKey.VALUE *!* UPDATE tblUpdate ; SET cField1 = ThisForm.cValue ; WHERE iField1 = ThisForm.txtKey.VALUE *!* The following two lines, taken together, do not cause the error. *!* loTextbox = ThisForm.txtValue *!* UPDATE tblUpdate ; SET cField1 = loTextbox.Value ; WHERE iField1 = 2 ENDPROC

PROCEDURE cmdUpdate.Error LPARAMETERS nError, cMethod, nLine =MESSAGEBOX(&quot;Error in UPDATE command: &quot; + MESSAGE ) RETURN ENDPROC

PROCEDURE cmdInsert.Click INSERT INTO tblUpdate ; VALUES (ThisForm.txtValue.Value, RECCOUNT + 1 ) ENDPROC

PROCEDURE cmdBrowse.Click BROWSE ENDPROC ENDDEFINE  Uncomment each UPDATE statement in turn to see the problem and the various workarounds.

Keywords: kbdatabase kbprb KB310569

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.