Delete a record from a form

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
 
S

Someone

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
 
A

Allen Browne

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
 
S

Someone

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top