Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Update record adds a value to the current value
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

seven
Senior Member

USA
1037 Posts

Posted - 09 July 2001 :  17:35:52  Show Profile  Visit seven's Homepage
I have a form that needs to submit a value to a recordset and add it to the value already in the record. For example:

1. Database Field1 = Value of 1

2. Submit form with Field1 value of 10

3. Database Field1 should now = Value of 11

Any ideas?

big9erfan
Average Member

540 Posts

Posted - 09 July 2001 :  18:12:27  Show Profile
There may be an easier way, but I do it like this

Request the needed recordset

variableName = recordset("field")

variableName = variableName + valueToAdd

Then run an Update on that table

e.x. Update Table_name Set field1 = value1, fieldToUpdate = variableName



http://www.ugfl.net/forums
Go to Top of Page

camusflage
Starting Member

USA
26 Posts

Posted - 10 July 2001 :  19:49:39  Show Profile
If you've got an updatable recordset, there is a cleaner way...

rsData!field = rsData!field + varValue/request.form.formfield/whatever

Mike



Go to Top of Page

Doug G
Support Moderator

USA
6493 Posts

Posted - 11 July 2001 :  00:17:35  Show Profile
quote:
If you've got an updatable recordset, there is a cleaner way...

rsData!field = rsData!field + varValue/request.form.formfield/whatever

Looks like the same thing 9erfan posted. The syntax isn't correct for asp/VBScript though.

An alternative way is to do the math with the SQL statement.
This snip assumes your connection is open and variables are Dim'd

<%
..
nAddValue = request.form("addfield")
sSql = "UPDATE table SET field = field + " & nAddValue
con.Execute(sSql)
..
%>

PS I like the sig, Mike! I'll probably remember it like I remember a pickup I saw years ago, decked out, and painted on each side was "Too Loose La Truck"



======
Doug G
======
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.33 seconds. Powered By: Snitz Forums 2000 Version 3.4.07