Question
One submit button - Insert Record and Update Record
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
%>
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
%>