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

delete command and backup record in another table

Status
Not open for further replies.

skaurd

Technical User
Jun 4, 2002
51
GB
Hi

I would like to create a customized delete command. Which enables a user to delete a record. But there may be 2 records with the same name, so when this occurs either give the user a pop up window to ask which one (select one) (maybe show another field, so that they can differentiate.).

OR when they click on delete, give them a drop down list of all records, they could select the one they want to delete. They are then prompted TWICE to ensure they really want to delete.

And I would like the deleted record to be stored in another table as back up once removed from that particular table.

Can anyone help?

thanks

S
 
Rather than go to the hassle of moving the "deleted" record to another table ( Which after all saves no space at all ) why no add a 'Current' field of type Yes/No to the table that defaults to Yes.

Then have all the forms that bind to that table include the
"Current = True" in the Where clause.

Then to Delete the record just set Current = False.

This will make 'undeleting' very much easier as well.


As for your choise of what and how to delete - I'm VERY concerned that you have "two records with the same name" as you put it.

What is the primary key for the record ?
Always select on that. ( those )
If you have a text field that is more meaningful to the user then use a combo box with the primary key in a bound column of zero width and the text fields in subsequent columns - as many as necessary to ensure that the user can accurately pick the desired record.

As for making sure that the user really wants to "delete" the record you can use:-
Code:
If MsgBox ("Do you really want to delete this record ? , vbYesNo,"Just Checking.") = vbYes Then

    If MsgBox("Are you treally, really sure?!, vbYesNo, "Still making sure") = vbYes Then
        Current = False
    End If
End If



'ope-that-'elps.

G LS


 
Right,

First thing to do is create a query which selects all the records with the particular name that the user has chosen to delete.

When the delete button is pressed, you could load a form which is based on this query and the user cycle through the records and press another delete button which warns the user twice about deleting the record and then deletes and closes down.

OR

You could have a Combo Box appear with it's row source based on the query, the user can then select the record to delete and on the AfterUpdate event of the combo box is where you would put th code to warn the user,twice, and then actually delete the record.

If you want to append the deleted record to another table then make sure you append the record before you delete. You could use either an append query or a make table query, depending on whther the table already exists.

It's going to take a fair bit of coding to do it either of these suggested ways, have you not got a primary key that the user can enter for a record to be deleted?

Hope that helps,

Pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top