Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can you have 2 <CFUPDATE>'s on 1 page?

Status
Not open for further replies.

Guest_imported

New member
Joined
Jan 1, 1970
Messages
0
Each record in the DB has 4 numbers and the total of those numbers (in the same record). When I <CFUPDATE> the 4 inputted numbers from a form page, I need to add them together to <CFUPDATE> that total into the same record.

The <CFUPDATE> page looks like this (in sections):

<CFUPDATE> area-updates 4 numbers from forms page,
<CFQUERY> area-since I need to read the 4 numbers,
<CFSET> area-to add the numbers that were posted,
<CFOUTPUT> area-I think its needed to read the record,
<CFUPDATE> area-to update the new sum into the same rec.
<HTML> area &quot;your info has been updated&quot;

But, the 2nd <CFUPDATE> doesn't do anything.

I need to do this on one page. The only thing I can think of is to use Frames which calls 2 other pages (one <CFUPDATE> would be invisible) and hope that it updates the one before the other (to add the posted numbers).

Any ideas would help.

Thank you in advance! I am very grateful.
 

I really try not to tell people they should do the whole thing different, but is there a really good reason for not adding the fields together first and doing one update ?

I think if you used a regular SQL update statement you would have no problem doing both operations in one Query.

Post the actual code for the 2 updates and I or somebody will help you write the SQL to make it work.

Have fun... Don't think too hard.
 
Yes, the reason is: I have to update the record to read the numbers that were just inputed a moment ago.

The form asks the user to input four numbers that need to be added. To actually add the numbers, I have to read the record since I do not know how to add the numbers without updating the record (since they havn't been updated yet).

Any ideas?
 
Great news! I figured out the problem: I have discovered that the original <CFUPDATE> wasn't updating the new sums because I didn't use the FORM scope on the variables.

Now my sections look like this after the form page:

<CFSET>
<CFUPDATE>
<HTML>

Where the <CFSET> section adds the 4 numbers and sets the SUM field for the <CFUPDATE>.

Thanks for your input!

-Tony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top