Updating a field in Access

Results 1 to 2 of 2

Thread: Updating a field in Access

  1. #1
    Join Date
    Dec 1969

    Default Updating a field in Access

    I&#039;m trying to update a field in Access based on the values in a different field. I thought I could use the update statement but when I do this it changes the values in every single field rather than the selected one. Here&#039;s my code<BR><BR>if ors("HorsePower")="0.5" then<BR> if ors("KW")&#060;&#062; "" then<BR> Response.Write "False" & "<BR>"<BR> else <BR> Response.Write "True" & "<BR>"<BR> ors.open "UPDATE VFDProductsAttributes SET KW =&#039;0.37&#039;", strconnect, 2,3<BR> end if<BR>end if <BR><BR>Any ideas? Thanks for your help

  2. #2
    Join Date
    Dec 1969

    Default Don't do it that way...

    ...at all.<BR><BR>Use SQL the right way:<BR><BR>UPDATE VRDProductsAttributes SET KW=0.37 WHERE HorsePower=0.5 AND KW IS NULL<BR><BR>WHY do you use quotes around values that are *NUMBERS*????<BR><BR>****************<BR><BR>If you insist on doing it your way:<BR><BR>if ors("HorsePower") = 0.5 then<BR>&nbsp; &nbsp; if ors("KW") &#060;&#062; "" then &#039; bad way to make this test!<BR>&nbsp; &nbsp; Response.Write "False&#060;BR/&#062;"<BR>&nbsp; &nbsp; else <BR>&nbsp; &nbsp; &nbsp; &nbsp; Response.Write "True&#060;BR/&#062;"<BR>&nbsp; &nbsp; &nbsp; &nbsp; ors("KW") = 0.37<BR>&nbsp; &nbsp; &nbsp; &nbsp; ors.Update<BR>&nbsp; &nbsp; end if<BR>end if <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