The problem I am running into is that the form is submitting twice to my database. It creates one good record and one blank record
The problem seems to be that in the form tag I have not stated an action which by default sets it to submit to itself.
This is the select statement that starts the form and gives it a unique ID and creates the record:
<%
Set objRS = Server.CreateObject("ADODB.Recordset"
'Adds one to the highest PNumber
strSQL = "SELECT MAX(Pnumber) AS PNumber FROM Pindex"
strSQL = "INSERT INTO PIndex (date_entered) VALUES ('" & Date() & "');"
strSQL = strSQL & "SELECT @@IDENTITY AS thisID;"
Set objRS = objConn.Execute(strSQL)
Set objRS = objRS.NextRecordSet()
intPNo = objRS("thisID"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
%>
Then is all the form stuff
Then I have an IF..THen statement that checks what is being sent to the database and updates the record that was created when the form was opened in the database and redirects the user to the next page
If NOT Request("ActionButton"
="" Then
If strDuration = "Permanent" and strActualDate ="" Then
strEnterData = "UPDATE PIndex SET Type_of_Process_Change = '" & strTypeChange & "', Requestor = '" & strRequestor & "', Location = '" & strLocation & "', "&_
"Part_Number='" & strPartNo & "', Project_ID='" & strProjectNo & "', Work_Center='" & strWorkCenter & "', Asset_Number='" & strAsset & "', "&_
"Work_Station='" & strStationNo & "', Operation_Number= '" & strOPNo & "', Current_Process_Condition='" & strCurrent & "', "&_
"Proposed_Process_Condition = '" & strProposed & "', Justification_for_Proposal= '" & strJustification & "', Action_Plan_for_Imp = '" & strAction & "', "&_
"Target_Date = '" & strTargetDate & "', MRB= '" & strMRB & "', Improvement='" & strImprovement & "', "&_
"Database_Updated= '" & strMFGPro & "', ECN_Number= '" & strECN & "', Customer_Complaint= '" & strCustComplaint & "', "&_
"Plant_Layout_Updated = '" & strPlantLayout & "', Duration = '" & strDuration & "', Estimated_Cost_Recovery =" & strEstCost & ", "&_
"Disposition_of_Request = '" & strDisRequest & "' WHERE PNumber = "& Request.QueryString("PNo"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
ElseIf strDuration ="Short Term" and NOT strActualDate ="" Then
strEnterData = "UPDATE PIndex SET Type_of_Process_Change = '" & strTypeChange & "', Requestor = '" & strRequestor & "', Location = '" & strLocation & "', "&_
"Part_Number='" & strPartNo & "', Project_ID='" & strProjectNo & "', Work_Center='" & strWorkCenter & "', Asset_Number='" & strAsset & "', "&_
"Work_Station='" & strStationNo & "', Operation_Number= '" & strOPNo & "', Current_Process_Condition='" & strCurrent & "', "&_
"Proposed_Process_Condition = '" & strProposed & "', Justification_for_Proposal= '" & strJustification & "', Action_Plan_for_Imp = '" & strAction & "', "&_
"Target_Date = '" & strTargetDate & "', Actual_Date= '" & strActualDate & "', MRB= '" & strMRB & "', Improvement='" & strImprovement & "', "&_
"Database_Updated= '" & strMFGPro & "', ECN_Number= '" & strECN & "', Customer_Complaint= '" & strCustComplaint & "', "&_
"Plant_Layout_Updated = '" & strPlantLayout & "', Duration = '" & strDuration & "', Estimated_Cost_Recovery =" & strEstCost & ", "&_
"Disposition_of_Request = '" & strDisRequest & "', Start_Date = '" & strStartDate & "', End_Date = '" & strEndDate & "' WHERE PNumber = "& Request.QueryString("PNo"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
End IF
If Request("ActionButton"
= "" Then
'Response.Write "Please enter Plan of Action before hitting submit."
Else
objConn.Execute(strEnterData)
'Response.Write(strEnterData)
Response.Redirect "Transition1.asp?intPNo=" &server.urlEncode(request("PNo"
) 'redirects to Transition page
End If
End If
%>
When I change the form tag to have an action to send to a different page the data doesn't go to the database.
I am new at this and really don't see where I am messing this up.
Can some one give me a clue as to what to change to get this to work.
Any help would be GREATLY appreciated .
Thanks
The problem seems to be that in the form tag I have not stated an action which by default sets it to submit to itself.
This is the select statement that starts the form and gives it a unique ID and creates the record:
<%
Set objRS = Server.CreateObject("ADODB.Recordset"
strSQL = "SELECT MAX(Pnumber) AS PNumber FROM Pindex"
strSQL = "INSERT INTO PIndex (date_entered) VALUES ('" & Date() & "');"
strSQL = strSQL & "SELECT @@IDENTITY AS thisID;"
Set objRS = objConn.Execute(strSQL)
Set objRS = objRS.NextRecordSet()
intPNo = objRS("thisID"
%>
Then is all the form stuff
Then I have an IF..THen statement that checks what is being sent to the database and updates the record that was created when the form was opened in the database and redirects the user to the next page
If NOT Request("ActionButton"
If strDuration = "Permanent" and strActualDate ="" Then
strEnterData = "UPDATE PIndex SET Type_of_Process_Change = '" & strTypeChange & "', Requestor = '" & strRequestor & "', Location = '" & strLocation & "', "&_
"Part_Number='" & strPartNo & "', Project_ID='" & strProjectNo & "', Work_Center='" & strWorkCenter & "', Asset_Number='" & strAsset & "', "&_
"Work_Station='" & strStationNo & "', Operation_Number= '" & strOPNo & "', Current_Process_Condition='" & strCurrent & "', "&_
"Proposed_Process_Condition = '" & strProposed & "', Justification_for_Proposal= '" & strJustification & "', Action_Plan_for_Imp = '" & strAction & "', "&_
"Target_Date = '" & strTargetDate & "', MRB= '" & strMRB & "', Improvement='" & strImprovement & "', "&_
"Database_Updated= '" & strMFGPro & "', ECN_Number= '" & strECN & "', Customer_Complaint= '" & strCustComplaint & "', "&_
"Plant_Layout_Updated = '" & strPlantLayout & "', Duration = '" & strDuration & "', Estimated_Cost_Recovery =" & strEstCost & ", "&_
"Disposition_of_Request = '" & strDisRequest & "' WHERE PNumber = "& Request.QueryString("PNo"
ElseIf strDuration ="Short Term" and NOT strActualDate ="" Then
strEnterData = "UPDATE PIndex SET Type_of_Process_Change = '" & strTypeChange & "', Requestor = '" & strRequestor & "', Location = '" & strLocation & "', "&_
"Part_Number='" & strPartNo & "', Project_ID='" & strProjectNo & "', Work_Center='" & strWorkCenter & "', Asset_Number='" & strAsset & "', "&_
"Work_Station='" & strStationNo & "', Operation_Number= '" & strOPNo & "', Current_Process_Condition='" & strCurrent & "', "&_
"Proposed_Process_Condition = '" & strProposed & "', Justification_for_Proposal= '" & strJustification & "', Action_Plan_for_Imp = '" & strAction & "', "&_
"Target_Date = '" & strTargetDate & "', Actual_Date= '" & strActualDate & "', MRB= '" & strMRB & "', Improvement='" & strImprovement & "', "&_
"Database_Updated= '" & strMFGPro & "', ECN_Number= '" & strECN & "', Customer_Complaint= '" & strCustComplaint & "', "&_
"Plant_Layout_Updated = '" & strPlantLayout & "', Duration = '" & strDuration & "', Estimated_Cost_Recovery =" & strEstCost & ", "&_
"Disposition_of_Request = '" & strDisRequest & "', Start_Date = '" & strStartDate & "', End_Date = '" & strEndDate & "' WHERE PNumber = "& Request.QueryString("PNo"
End IF
If Request("ActionButton"
'Response.Write "Please enter Plan of Action before hitting submit."
Else
objConn.Execute(strEnterData)
'Response.Write(strEnterData)
Response.Redirect "Transition1.asp?intPNo=" &server.urlEncode(request("PNo"
End If
End If
%>
When I change the form tag to have an action to send to a different page the data doesn't go to the database.
I am new at this and really don't see where I am messing this up.
Can some one give me a clue as to what to change to get this to work.
Any help would be GREATLY appreciated .
Thanks