Update Statement

Results 1 to 2 of 2

Thread: Update Statement

  1. #1
    Join Date
    Dec 1969

    Default Update Statement

    Hi all.<BR>Is there an easy way to increase a field value without finding what the value in field is?<BR>i.e. Field contains value of 100<BR>and i want to add 20 to it so new value is 120.<BR><BR>I&#039;m using an Access2000 DB<BR>Note: the values i add to field will be different and set in coding.<BR>Note: the values in field will be different from 1 record to another, but i&#039;m only updating 1 at a time.<BR><BR>Do i need to first find the record<BR><BR>strIncrease = "20"<BR>Select "T1.ID, T2.Size From Table1 Where ((T1.ID)="&strID") "<BR><BR>strOldValue = (rs.Fields("T1.Size"))<BR><BR>strNewValue = (strOldValue + strIncrease)<BR><BR>"Update Set T2.Size = strNewValue WHERE ((T1.ID)="&strID") "<BR><BR><BR>Im looking to do this with less trips to the database if possible?<BR><BR>Thanks for the help.<BR><BR>Russell M

  2. #2
    Join Date
    Dec 1969

    Default So easy it will scare you

    &#060;%<BR>SQL = "UPDATE Table1 SET [Size] = [Size] + " & increase & " WHERE [ID] = " & id<BR>conn.Execute( SQL )<BR>%&#062;<BR><BR>You have REAL problems in that ASP code you were showing. It would never work, as you gave it. I hope you knew that.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts