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

Controlling Record Deletion

Status
Not open for further replies.

JezzaHyde

Programmer
Jul 29, 2002
29
AU
Hey folks,
I'm having difficulty figuring out how to allow (or not allow) a record to be deleted, based on the actions of the user in another form.

Here's the scenario:
When the user choses to delete a record, a pop-up form appears, requesting the ID of the user to be inputted into a text box. Upon the submission of this form, the User ID is appended to a register to keep track of who deleted what records. Here's my pickle, i want to be able to delete the record if the user sumbits the ID, or not delete it if the user cancels the form. Any ideas??

I hope this is enough info....thanks for any advice

-Jezza
 

On the main form have the cmdDeleteThisRecord button's On_Click event append the Record's PrimaryKey to the PopUp Form using the OpenArgs property


Private Sub cmdDeleteThisRecord_Click()

DoCmd.OpenForm "popfrmCheckAndDelete", , , , , , PrimeKeyControlName
Me.Requery


Then on the pop-up form

In the UserId_AfterUpdate event:-

If UserIdValidated Then
Append data to Delete Log
DoCmd.RunSQL "DELETE FROM tblName WHERE PrimeKeyField = " & OpenArgs
Else
MsgBox "UserId was not valid. No Delete will take place.",,"Bye."
End IF


When the PopUp closes after a successful delete all of the bound controls on the form will display "#Deleted". So the Me.Requery line is there to get rid of that effect.




'ope-that-'elps.

G LS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top