User interface for deleting a record form a table

W

wolfpack

How do I go about allowing a user to delete a record from a table. Here is
my situation.

I have a main menu with command buttons. One of the button reads "Remove
Reviewer". Right now the buttton does nothing.

What I would like is when it is clicked to have a window open that allows
the user to select a name (drop down menu I suppose) from the "reviewers"
table. Once the name is selected I would like for the user to click on a
button that says "Remove this Reviewer". Once this happens, the reviewer
would be removed from the table along with any other info in that row.

Thanks for the help and I apologize if this is not in the correct section.
 
D

Dorian

Your design will work. The only problem I see is if the reviewer is referred
to by another table, you could have referential integrity issues.
It's always best to display a confirmation screen before deleting any record.
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".
 
P

Piet Linden

How do I go about allowing a user to delete a record from a table. Here is
my situation.

I have a main menu with command buttons. One of the button reads "Remove
Reviewer". Right now the buttton does nothing.

What I would like is when it is clicked to have a window open that allows
the user to select a name (drop down menu I suppose) from the "reviewers"
table. Once the name is selected I would like for the user to click on a
button that says "Remove this Reviewer". Once this happens, the reviewer
would be removed from the table along with any other info in that row.

Thanks for the help and I apologize if this is not in the correct section..

use an unbound form with a combobox. If you want, include the primary
key from the table in the combo in one of the columns (could be
hidden). then in the Query,
just reference the hidden column

DELETE *
FROM Reviewers
WHERE ReviewerID=Forms!MyForm!MyCombo.Column(0);
(Column 0 is the "leftmost" column).

that would work from a query, but you would need to use SetWarnings to
shut off the "Are you sure..." messages.

So you could do this:

dim lngPK as Long
lngPK=Forms!MyForm!MyCombo.Column(0)

strSQL = "DELETE * FROM Reviewers WHERE ReviewerID=" & lngPK

CurrentDB.Execute strsql, dbFailOnError

Allen Browne has some nice notes on returning # of records affected
etc.
www.allenbrowne.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top