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

Restricting Deletion to One record only in a Subform 1

Status
Not open for further replies.

raabbasi

Technical User
Jun 21, 2005
52
PK
Is it possible to restrict Deletion to One record only in a Subform (datasheet view), that is disallowing user the multiple-selection of records.
The ultimate purpose of this action is recalculating the totals etc. affected by the deletion of records.
 
Hi
This post also occurs at thread705-1086896.

I think it would be easiest to set Allow Deletes to false and then provide a Delete button.
 
Thanks for the suggestion.
It does not look nice to put Delete button in front of each of the hundreds of records (in datasheet view).
Hopefully, someone may come up with another solution!
 
Raabbasi
It is not necessary to put a delete button on each line of a datasheet, it is not even possible. The delete button should be put on the main form.
Code:
Private Sub cmdDelete_Click()
SQL = "Delete * from tblTable where ID =" & Me.SubformControlName.Form.ID
DoCmd.RunSQL SQL
Me.SubformControlName.Requery
End Sub
 
Thanks Remou. I had mis-understood first.
 
Hi Raabbasi

How about using the on delete event to set (true) a flag (a binary field in an admin table) and only allow a delete if the flag is not set (false). This flag could be unset whenever the form is loaded or opened.

Ian Mayor (UK)


Program Error
Programmers do it one finger at a time!
 
Thanks Ian mayor for another idea. It can help in many situations, like this one.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top