Re: Delete



Thanks Again Allen

Regards

John

"Allen Browne" <AllenBrowne@xxxxxxxxxxxxxx> wrote in message
news:OnZkqzCHGHA.2472@xxxxxxxxxxxxxxxxxxxxxxx
> There could be several reasons why Access can't delete now.
>
> Examples:
> a) The form is unbound.
>
> b) The form is at a new record, where there is nothing to delete.
>
> c) There is an entry in progress that cannot be saved (e.g. required field
> missing), and so the delete cannot occur.
>
> d) The form's AllowDeletions property is No, or the user does not have
> permission to delete.
>
> e) The focus is in a text box where the user has entered something
> invalid, such as 1/16/ in a date field, or "two" in a number field, or
> backspaced out characters in a required field. Access won't let them out
> of the box until they fix the entry or press <esc> to undo it.
>
> f) The event you are using is unsuitable.
>
> This solves some of the problems above (b and c):
>
> Private Sub cmdDelete_Click()
> If Me.Dirty Then
> Me.Undo
> End If
> If Not Me.NewRecord Then
> DoCmd.SetWarnings False
> RunCommand acCmdDeleteRecord
> DoCmd.SetWarnings True
> End If
> End Sub
>
> Other options for deletion without confirmation include using the
> BeforeDelConfirm event of the the form to suppress the confirmation.
>
> Or you can delete from the RecordsetClone of the form:
>
> If Me.Dirty Then
> Me.Undo
> End If
> If Not Me.NewRecord Then
> With Me.RecordsetClone
> .Bookmark = Me.Bookmark
> .Delete
> End With
> End If
>
> --
> Allen Browne - Microsoft MVP. Perth, Western Australia.
> Tips for Access users - http://allenbrowne.com/tips.html
> Reply to group, rather than allenbrowne at mvps dot org.
>
> "John" <johnlee2509@xxxxxxxxxxxxxxx> wrote in message
> news:OLykhPCHGHA.1396@xxxxxxxxxxxxxxxxxxxxxxx
>> Hi,
>> Using the "DoCmd.RunCommand acCmdDeleteRecord" statement, how do I set
>> this to works silently?
>> I have set the SetWarnings to False but I get an error message saying
>> "cannot delete now" or words to that effect.
>> If I comment out the SetWarnings Statement the record is deleted but I am
>> prompted which I want to avoid.
>>
>> Regards
>>
>> John
>
>


.



Relevant Pages

  • Re: IRDA support
    ... >> Dear John, ... And I am using the same irda hardware! ... >> Regards, ...
    (microsoft.public.windowsxp.embedded)
  • Re: Printing Emails - Changing Fonts
    ... >>> Your friend sends you detailed instructions on how to repair your ... >>> television/car/washing machine. ... >>> Regards, ... >>> John. ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)
  • Re: got more proof
    ... money they are making, OK, I'll listen to the hype. ... John, ... Your loss, and I am sorry for that, with my 50 plus years of ... Regards, ...
    (misc.invest.stocks)
  • Re: Undo and Redo commands greyed out
    ... "John" wrote: ... Best regards ... general code or an add-in for example. ... following into the Immediate window of the VBE (Alt+F11 then ctrl+G to ...
    (microsoft.public.visio.general)
  • Re: Resetting Page Number based on Group
    ... Regards ... Perth, Western Australia. ... rather than allenbrowne at mvps dot org. ...
    (microsoft.public.access.reports)