DB newbie here - I have MS Access table with the following fields PressID, PRTitle, Month, Day, and Year. Once the information is posted I want to be able to update/edit if necessary.
The following is the code I have used to list the current data: With the html removed
<cfquery name="pressreleaselist" datasource="safedb">
SELECT * FROM PressRelease
ORDER BY Month ASC, Day DESC, Year DESC
</cfquery>
<cfoutput query="pressreleaselist">
<a href="updatepressreleaseform.cfm?Month=#Month#&Day=#Day#&Year=#Year#">#MonthAsString('#Month#')# #Day#, #Year# #PRTitle#
</cfoutput>
on updatepressrelease page I use the following code:
<cfquery name="pressreleaselist" datasource="safedb">
SELECT * FROM PressRelease
WHERE Month=#URL.Month# AND Day=#URL.Day# AND Year=#URL.Year#
</cfquery>
Inside the CFFORM I have added the following to embed the primary key:
<cfoutput>
<input type="hidden" name="PressID" value="#pressreleaselist.Month&Day&Year#">
</cfoutput>
This is followed by inputs for the various fields.
On the final edit page I have used the following code:
<cfquery datasource="safedb">
UPDATE PressRelease
SET Month='#Trim(FORM.Month)#',
Day='#Trim(FORM.Day)#',
Year='#Trim(FORM.Year)#',
PRTitle='#Trim(FORM.PRTitle)#',
PressRelease='#Trim(FORM.PressRelease)#'
WHERE PressID=#FORM.PressID#
</cfquery>
When I view the results I see that instead of editing the existing record it has inserted a new.
Any suggestions as to what I am doing wrong?
Thanks again from a newbie!
The following is the code I have used to list the current data: With the html removed
<cfquery name="pressreleaselist" datasource="safedb">
SELECT * FROM PressRelease
ORDER BY Month ASC, Day DESC, Year DESC
</cfquery>
<cfoutput query="pressreleaselist">
<a href="updatepressreleaseform.cfm?Month=#Month#&Day=#Day#&Year=#Year#">#MonthAsString('#Month#')# #Day#, #Year# #PRTitle#
</cfoutput>
on updatepressrelease page I use the following code:
<cfquery name="pressreleaselist" datasource="safedb">
SELECT * FROM PressRelease
WHERE Month=#URL.Month# AND Day=#URL.Day# AND Year=#URL.Year#
</cfquery>
Inside the CFFORM I have added the following to embed the primary key:
<cfoutput>
<input type="hidden" name="PressID" value="#pressreleaselist.Month&Day&Year#">
</cfoutput>
This is followed by inputs for the various fields.
On the final edit page I have used the following code:
<cfquery datasource="safedb">
UPDATE PressRelease
SET Month='#Trim(FORM.Month)#',
Day='#Trim(FORM.Day)#',
Year='#Trim(FORM.Year)#',
PRTitle='#Trim(FORM.PRTitle)#',
PressRelease='#Trim(FORM.PressRelease)#'
WHERE PressID=#FORM.PressID#
</cfquery>
When I view the results I see that instead of editing the existing record it has inserted a new.
Any suggestions as to what I am doing wrong?
Thanks again from a newbie!