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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADO Delete Record Question 2

Status
Not open for further replies.

Jdoggers

Technical User
Feb 20, 2005
43
US
Hi,
I have a Access database that im using ADO connections to communicate with. I am having a problem with deletion of a single record in a table. There is a dropdown combo box that i use to choose which file to delete. This combobox, called "combo1" is filled with the "name" field of each record in the database. Then im taking the index number of that option, and trying to delete the corresponding record in the database. the .listindex property corresponds exactly with the recordset.fields.item("name") index number. Anyone got any ideas on how to delete the record from the table. Oh, i almost forgot, why do i need to close the connection then reopen it to update the combobox, why cant i just use the .update method. thanks
 
you can alwyas issue a "delete from table where my_key = selected_key_value".

This may mean changing from the BOUND control you are using to a UNBOUND one and doing everything by code (as it should have been in the first place)



Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
If you start deleting records then combo box .listindex property might no longer correspond exactly to the field index value that you want it to. I would recommend placing this key value in the combo box .itemdata property that corresponds to the field value in the list property. That way you will always have a correct corresponding value.

I also agree with Frederico in that you might want to change to unbound controls. This will requirte some more coding (not too much) but you will like the overall control that you will gain.

zemp
 
I also agree with zemp and frederico. If you're going to use the itemdata property, make sure your key is an integer. I got caught out once trying to use alpha characters in a key and assigning it to the itemdata property.

Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top