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

Not allowing deletions when a record meets certain criteria 1

Status
Not open for further replies.

WallT

Vendor
Aug 13, 2002
247
US
I have a subform that is datasheet view. It is activities for an order. I want users to be able to delete/edit these activities as needed accept for certain activities. Most are fine, however, if the ActivityCode is "WE" (Work Order Entered), then I dont ever want that to be edited or deleted by users. I don't know where or how to go about this...ie...

If ActivityCode = "WE" Then
Dont allow edits or deletions on just that record
End if

If somebody could point me in the right direction I would be greatful. Thank you.
 
How are ya WallT . . .

In the [blue]On Current[/blue] event of the subform, try this:
Code:
[blue]   Dim flg As Boolean
   
   If Not ActivityCode = "WE" Then flg = True
   Me.AllowEdits = flg
   Me.AllowDeletions = flg[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
Another way to do it is by checking the status of ActivityCode in the BeforeDelConfirm event of the form, and cancelling the delete if the value is "WE". That would cover the scenario where:
1. User navigates to record, and the value is not "WE"
2. User changes value to "WE"
3. User tries to delete record


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top