Skip to main content
Known Participant
December 5, 2008
Question

One submit button - Insert Record and Update Record

  • December 5, 2008
  • 2 replies
  • 570 views
I have a form in Dreamweaver CS3, using ASP VBScript and an Access database. When submitted, the form inserts a record into the table CountDate01. The record comes from a hidden field that gets its value from a field within that same table. There is no other data entered by the user in any other form fields. The info the form submits comes from: rsDate1Avail.Fields.Item("Date01").Value

I would like if the same Submit button could also update a record in a second table (registrants) at the same time. I would like to submit the same info that comes from the hidden field to the second table. So it would be two actions occurring that both insert and update in 2 different tables from one submit button. Is this possible?

Here is the code for the existing form action:

<%
If (CStr(Request("MM_insert")) = "submitDate1") Then
If (Not MM_abortEdit) Then
' execute the insert
Dim MM_editCmd

Set MM_editCmd = Server.CreateObject ("ADODB.Command")
MM_editCmd.ActiveConnection = MM_MumConn_STRING
MM_editCmd.CommandText = "INSERT INTO CountDate01 (Date01) VALUES (?)"
MM_editCmd.Prepared = true
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 135, 1, -1, MM_IIF(Request.Form("hiddenField"), Request.Form("hiddenField"), null)) ' adDBTimeStamp
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close

' append the query string to the redirect URL
Dim MM_editRedirectUrl
MM_editRedirectUrl = "form_FT_4.asp"
If (Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
Response.Redirect(MM_editRedirectUrl)
End If
End If
%>
This topic has been closed for replies.

2 replies

MarnitaMAuthor
Known Participant
December 6, 2008
Well, I thought that I might have to do some hand-coding. Can you perhaps give me a hint as to how to structure the code? I've played around with it a bit but haven't been successful in figuring it out.
MarnitaMAuthor
Known Participant
December 8, 2008
Anyone have any ideas?
Inspiring
December 6, 2008
>I have a form in Dreamweaver CS3, using ASP VBScript and an Access
>database.
> When submitted, the form inserts a record into the table CountDate01. The
> record comes from a hidden field that gets its value from a field within
> that
> same table. There is no other data entered by the user in any other form
> fields. The info the form submits comes from:
> rsDate1Avail.Fields.Item("Date01").Value
>
> I would like if the same Submit button could also update a record in a
> second
> table (registrants) at the same time. I would like to submit the same info
> that
> comes from the hidden field to the second table. So it would be two
> actions
> occurring that both insert and update in 2 different tables from one
> submit
> button. Is this possible?



Yes. Use a command on the redirect page to update the data. No, wait, the
ASP COMMAND IMPLEMENTATION IS BROKEN IN CS3, and remains broken in CS4. So
sorry, you'll have to hand-code it.

Sorry, I'm just a little bit bitter about the callous attitude Adobe has
shown in fixing the KNOWN BUGS IN THEIR SOFTWARE.