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

Using List box to delete records? 1

Status
Not open for further replies.

Sen7inel

IS-IT--Management
Feb 14, 2001
90
0
0
FI
Hello. I'm new here, and very novice with Access, so try to bear with me. =)

I'm working on an Access project, with a database on a little MSDE server.

I'm trying to make a form that has a list box, from which the user is supposed to select a record and then delete it by clicking on a button. Ok now, I have the box, the records in it and a button that is supposed to delete the record chosen and then requery the box. If I choose only the first record in the list and delete that everything works fine, but if I choose some other, I get a notification that tells me that primary key constraint can't allow duplicate names. What is with this? The list box isn't exactly "choosing" anything or what?
 
You must have the list box bound to a field in the underlying table. When you choose a value other than the one the bound field already has, the effect is to try to update the bound field in the table. Apparently this is your key field, so you're trying to change the key to the same key as another record has.

If you just make the field unbound by erasing its Control Source property, I think it will probably work. Rick Sprague
 
Hm, according to the navigation buttons, if I bound the list box choosing the records from the box doesn't actually change the current record. Then, if I use the nav buttons to go thru the records, the list hilights the record I've selected and deleting it goes fine. If I unbound the box, the result is the same except that the box doesn't hilight anything. Thus, it would appear that the list box is merely a "decoration" here, showing the records all right but not giving any fuctionality.
 
Duh, forget about that, I got it now (had a stupid error there). Thanks for help, Rick!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top