Delete a record from a form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have form and I want to be able to delete a single record and all cascading
records.

I have a delete command button, but it does not work.
None of the records are deleted. I would like to know what code i need use
for the record to delete.

DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

this does not work

Ty in advance for you help
 
Sibes

Try this instead:

DoCmd.RunCommand acCmdSelectRecord

For cascading records, you need to ensure that the relationship you have
between the tables in question have the 'Cascade Delete Related Records'
option checked.

M
 
SelectRecord won't perform a delete, of course.

Try something like this in your event procedure:

If Me.Dirty Then
Me.Undo
End If
If Not Me.NewRecord Then
RunCommand acCmdDeleteRecord
End If
 
Hmm, what on earth was I thinking? *puzzled*

Thanks for noticing that.

SelectRecord won't perform a delete, of course.

Try something like this in your event procedure:

If Me.Dirty Then
Me.Undo
End If
If Not Me.NewRecord Then
RunCommand acCmdDeleteRecord
End If
 
Back
Top