Question Add/Delet item from listbox

josephbupe

Registered User.
Local time
Today, 11:12
Joined
Jan 31, 2008
Messages
247
Hi,

I have two list boxes on a form. The first listbox contains CATEGORIES and the second contains ITEMS that belong to respective categories. So, when i click a category the next listbox displays the items that belong to that particular category.

I need to know how to add new items to a selected category and also delete items from a selected category. If no category is selected or item already exixts, item should not add.

I will appreciate.

Joseph
 
It sounds like you have a one-to-many relationship with Categories and Items, with a foreign key in Items to tell which category belongs to.

Create a form for the the Items table, and open it with a button from your listbox form with the selected Item as an argument.

Your selected item will show in your new form with its associated Category. You can then change to another category, set it to Null (if it is in your Category list), or delete the record.

You can have another button call the same form in Add mode to add a new Item and set its Category.

Set the Item Name field in your table as Indexed (No duplicates) to prevent an existing item from being entered.

If you instead have a many-to-many relationship between your two tables (one item can also belong to more than one category), then you would perform a similar operation on your junction table.
 

Users who are viewing this thread

Back
Top Bottom