Override the Del function

  • Thread starter Thread starter Nes
  • Start date Start date
N

Nes

I have a form whose recordset is readonly. When a user presses the
delete key I would like to delete a record on a separate table that is
related to the recordset. How do I get the code behind forms (to
perform the delete that I want) to work when delete is forbidden on the
recordset for the form?
 
Hi,


Set the form to preview the keystrokes (KeyPreview=true) and in the keyup
event, do the deletion:


------------------
Private Sub Form_Load()
Me.KeyPreview = True
End Sub
----------------
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
if(46=KeyCode) then
DoCmd.RunSQL "DELETE FROM tableName WHERE ... some_condition_here "
end if
End Sub
 
Back
Top