Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dropdown listbox creates problem with code

Status
Not open for further replies.

mnongkhlaw

Programmer
Feb 22, 2002
62
0
0
IN
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 :

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
 
Perhaps I did not make things clear enough, so I'm re-posting in another way : I'd like to use a drop-down listbox DTC rather than the RecordsetNavBar to jump to any record for editing (Update button enabled). However, for adding data (Add button), I need to disable/hide this listbox and instead, enable a text box which is linked to comp_id field for the user to enter a new comp_id. What are the events I should code for if I still prefer using FormManager DTC? When the user enters an existing comp_id, he should be informed and prevented from doing so.

Would be grateful if examples or pointers to similar applications are given.

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top