There's a lot in your code that should probably be changed -- first, I'm
assuming that the form/database code at the bottom of your post is NOT part
of the same page as the form -- but you don't need the cfoutput tags in the
processing code, or most of the hash signs, and you could avoid the use of
Evaluate.
But most importantly, there are two big problems in the database code if
this is supposed to be an "update" (you say the user is modifying the
answers.
<cfif isDefined("form.fieldnames")>
> <cfquery name="qryInsert" datasource="cfelsunrise" dbtype="odbc">
>
> insert into survey_results (surveyidfk, empID) values (#url.survey#,
> #session.EmpID#)
Here you're always doing an "insert" -- creating a new survey result record.
Is that what you're really trying to do? You said "modify," but you're
saving a new record.
Then ...
<CFLOOP LIST="#form.fieldnames#" Index="field">
> <cfif #field# neq "btnSubmitSurvey" and #field# neq "btnSubmitSurvey2">
>
>
> <cfquery name="qryInsert1" datasource="cfelsunrise"
> dbtype="odbc">
> delete from SurveyResultsDetail where idfk
> =#qryInsert.newID#
> insert into SurveyResultsDetail
> (answer,surveyID,idfk) values
> (#ListLast(Evaluate("Form.#field#"),"_")#,#url.survey#,#qryInsert.newID#)
> </cfquery>
> <cfelse>
>
> </cfif>
> </CFLOOP>
..... you are trying to delete records from the Detail table based on the ID
of the new record, and there aren't any in the first iteration of the loop.
You just created the Results record. Then you're immediately inserting a
record into the Details table. But you are doing this within the loop of
the fieldnames, so the next iteration of the loop deletes the record you
just created. At the end you have one Detail record, from the last iteration
of the loop, and it's related to the new Result record you just created.
--
Thanks,
Tom
Tom McNeer
MediumCool
http://www.mediumcool.com
1735 Johnson Road NE
Atlanta, GA 30306
404.589.0560
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:304670
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4