delete record without prompt


G

Guest

I have a form with a sub form that has a button to copy the displayed form
and subform. Users can then change date and make edits if needed for their
current monthly reports.
If the date is not changed it will delete the record on close. Howerver it
prompts me if I want to delete record. How can I delete the record with out
the prompt? I want it to delete without the user knowing anything is deleted.

The below code is what I am using in the Unload form event.


If Me.ReportDt = 1 Then
Me.AllowEdits = True
Forms!f4KPIEdit.Form!f4KPIEditDetails.Form.AllowEdits = True
Me.AllowDeletions = True
Forms!f4KPIEdit.Form!f4KPIEditDetails.Form.AllowDeletions = True
' Me.Undo
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
End If

Thanks in advance
 
Ad

Advertisements

K

Kerry

Before deleting add
DoCmd.SetWarnings False

After deleting add
DoCmd.SetWarnings True
 
G

Guest

I already have the docmd.setwarnings false
but I think it needs more since the copy command copied the subform data to
a table. It is doing a cascade delete.
 
Ad

Advertisements

J

John W. Vinson

I have a form with a sub form that has a button to copy the displayed form
and subform. Users can then change date and make edits if needed for their
current monthly reports.
If the date is not changed it will delete the record on close. Howerver it
prompts me if I want to delete record. How can I delete the record with out
the prompt? I want it to delete without the user knowing anything is deleted.

The below code is what I am using in the Unload form event.


If Me.ReportDt = 1 Then
Me.AllowEdits = True
Forms!f4KPIEdit.Form!f4KPIEditDetails.Form.AllowEdits = True
Me.AllowDeletions = True
Forms!f4KPIEdit.Form!f4KPIEditDetails.Form.AllowDeletions = True
' Me.Undo
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
End If

Thanks in advance

You're using the Form to delete records... and using moldy ancient menu code
to do it. The data is, of course, not in the form; it's in a Table, and it's
from the Table that you want it deleted! You'll probably be much better off
creating a Delete query and executing it using the Querydef Execute method.
It's not clear to me just what's being deleted and how you decide.

John W. Vinson [MVP]
 

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