mnongkhlaw
Programmer
Hi folks,
This problem's been bugging me for quite a while :
I use an ASP (computer.asp) with DTCs bound to fields of an MS Access table (computer) and 2 recordset DTCs, Recordset1 and rsComp as well as RecordsetNavBar and Add, Update, Delete, Save and Cancel buttons. The source of data for Recordset1 is a simple SQL statement "Select * from computer where comp_id=?". The source of data for rsComp is simply the table (computer). I use the Form Manager DTC to control the modes (Edit/Add) and buttons of the form. I have tested that the page works correctly in all the modes when I use just the RecordsetNavBar DTC. Since there are may records existing in the table, I added a dropdown list DTC bound to rsComp with bound column comp_id to enable the user to jump to any comp_id for record editing purposes. In "Add" mode, when I try to enter a new record and click on the "Save" button, I always get the error message generated by my code (given below) even when its a new (not existing) comp_id :
I found that the dropdown list is the culprit because when I remove it, the record is added without the above error message, but I still need the ability to jump to a record instantly instead of using the RecordsetNavBar for editing purposes.
How do I resolve this problem?
Mark
This problem's been bugging me for quite a while :
I use an ASP (computer.asp) with DTCs bound to fields of an MS Access table (computer) and 2 recordset DTCs, Recordset1 and rsComp as well as RecordsetNavBar and Add, Update, Delete, Save and Cancel buttons. The source of data for Recordset1 is a simple SQL statement "Select * from computer where comp_id=?". The source of data for rsComp is simply the table (computer). I use the Form Manager DTC to control the modes (Edit/Add) and buttons of the form. I have tested that the page works correctly in all the modes when I use just the RecordsetNavBar DTC. Since there are may records existing in the table, I added a dropdown list DTC bound to rsComp with bound column comp_id to enable the user to jump to any comp_id for record editing purposes. In "Add" mode, when I try to enter a new record and click on the "Save" button, I always get the error message generated by my code (given below) even when its a new (not existing) comp_id :
Code:
Sub cmdSave_onclick()
Response.Clear
if Recordset1.isOpen() then
Recordset1.close
end if
dim para1
para1=txtCompID.value
Recordset1.setParameter 0,para1
Recordset1.open
if not Recordset1.EOF or not Recordset1.BOF then
Recordset1.close
rsComp.cancelUpdate
Response.Write ("<B><H2><FONT COLOR=Red>Error : You entered a duplicate Computer ID</H2></B></FONT><BR>")
Response.Write "<A HREF=computer.asp>Go Back</A>"
Response.End
end if
End Sub
I found that the dropdown list is the culprit because when I remove it, the record is added without the above error message, but I still need the ability to jump to a record instantly instead of using the RecordsetNavBar for editing purposes.
How do I resolve this problem?
Mark