none
Why won't this commit to the local FoxPro Table?

    Question

  • Each time I run this statement on the form I receive the following error:

    Alias "txtdescription" is not found.

     

     

    UPDATE adtype ;
      SET adtype.description = ALLTRIM(Thisform.txtDescription.Value), ;
       adtype.rate = ALLTRIM(Thisform.txtrate.Value), ;
       adtype.priority = ALLTRIM(Thisform.txtpriority.Value), ;
       adtype.headingnum = ALLTRIM(thisform.cbopageType.Value) ;
      WHERE adtype.booktype = cAddEditAdtype.booktype AND ;
         adtype.bookcode = cAddEditAdtype.bookcode AND ;
         adtype.adtype = cAddEditAdtype.adtype

     

     

    Thanks in advance, I think it is something very simple, but not obvious to me.

     

    RPP

    Monday, August 06, 2007 7:53 PM

Answers

  • It's better to not use thisform properties (objects) in UPDATE, SELECT, INSERT statements but rather local variables.

     

    Code Snippet

    local lcNewDescrip, lcNewRate, lcNewPriority, lcNewHeadingNum

    lcNewDescrip = ALLTRIM(Thisform.txtDescription.Value)

    lcNewRate = ALLTRIM(Thisform.txtrate.Value)

    lcNewPriority = ALLTRIM(Thisform.txtpriority.Value)

    lcNewHeadingNum = ALLTRIM(thisform.cbopageType.Value)

     

    UPDATE adtype ;
      SET adtype.description = m.lcNewDescrip, ;
       adtype.rate = m.lcNewRate, ;
       adtype.priority = m.lcNewPriority, ;
       adtype.headingnum = m.lcNewheadingNum ;
      WHERE adtype.booktype = cAddEditAdtype.booktype AND ;
         adtype.bookcode = cAddEditAdtype.bookcode AND ;
         adtype.adtype = cAddEditAdtype.adtype

     

     

    Monday, August 06, 2007 7:56 PM