Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / March 2008

Tip: Looking for answers? Try searching our database.

Wizard's delete command

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Robert - 23 Jan 2008 05:08 GMT
If you use the wizard to drop a delete button on a form, it generates the
following code:
   DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
   DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
Why doesn't it just do  DoCmd.RunCommand acCmdDeleteRecord ?

Robert
Jeanette Cunningham - 23 Jan 2008 10:29 GMT
Robert,
it does this to keep compatibility with older versions of Access that used
this code. It does a similar thing for other button code it generates.

Jeanette Cunningham

> If you use the wizard to drop a delete button on a form, it generates the
> following code:
[quoted text clipped - 3 lines]
>
> Robert
Allen Browne - 23 Jan 2008 14:24 GMT
The Wiz. code is really ancient, not not good code.

Try something like this:
   If Me.Dirty Then Me.Undo
   If Not Me.NewRecord Then RunCommand acCmdDeleteRecord

What this does is to undo any changes that are in progress (since you are
going to kill the record anyway), and also avoids the error when there is no
record to delete.

Signature

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.

> If you use the wizard to drop a delete button on a form, it generates the
> following code:
[quoted text clipped - 3 lines]
>
> Robert
Robert - 23 Jan 2008 18:22 GMT
Thanks.
> The Wiz. code is really ancient, not not good code.
>
[quoted text clipped - 13 lines]
>>
>> Robert
Access User - 19 Mar 2008 15:56 GMT
I came upon this posting as I have tried this 'wizard' thing myself and found
it did little more than make an obnoxious sound. That having been said,
here's the event click code

Private Sub Command96_Click()

On Error GoTo Err_Command96_Click

   If Me.Dirty Then Me.Undo
   If Not Me.NewRecord Then RunCommand acCmdDeleteRecord

Exit_Command96_Click:
   
Exit Sub

Err_Command96_Click:
   MsgBox Err.Description
   Resume Exit_Command96_Click
   
End Sub

that I have modified per your posting....no compilation problems but when
clicked, the cmd button results in a message claiming

"The command or action 'DeleteRecord' isn't available now" :-(

?????

> The Wiz. code is really ancient, not not good code.
>
[quoted text clipped - 13 lines]
> >
> > Robert
Allen Browne - 20 Mar 2008 01:54 GMT
Is this form bound to a table or query?

Is its AllowDeletions property set to Yes?

Can you edit the records in this form, or is it read-only?

If it is a secured database, do you have adequate permissions?

Signature

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.

>I came upon this posting as I have tried this 'wizard' thing myself and
>found
[quoted text clipped - 24 lines]
>
> ?????
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.