PC Review


Reply
Thread Tools Rate Thread

Delete Record Command Button

 
 
=?Utf-8?B?ZGljZWo=?=
Guest
Posts: n/a
 
      25th Feb 2005
I created my database in Access 2000 and my company recently upgraded to
2002. Certain people are still using 2000 in my organization however so I
don't want to convert my db yet.

Problem: I have a button on a form that the button wizard set up to delete
a record. Previously it worked fine.

While it still deletes the active record on my form, it now also gives an
error message that says "No current record." This appears after the record
is deleted.

The VBA code that the wizard created is:
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

I know those numbers refer to Access 95 commands but I don't know what they
are. I still haven't figured out VBA very well...

Curiously, if I select Delete Record from the menu, the error message
doesn't appear so the code is not the same.

How can I stop that error message from appearing?
Thanks


 
Reply With Quote
 
 
 
 
Allen Browne
Guest
Posts: n/a
 
      25th Feb 2005
This is a known problem with Access 2002 SP3. This particular version/patch
reports the "No Current Record" error immediately after the deletion, and
then sorts itself out again quickly.

Temporarily comment out the error handler, and get the actual number for the
error. Then change the error handling part of the routine so it just ignores
this error, i.e.:
If Err.Number <> xxxx Then
MsgBox ...
End If

What the wizard code does is fire off the 9th item on the Edit menu in A95
(the first record is zero), which is Select Record. Then it fires the 7th
item on the Edit menu, which is the Delete.

A better way to code this would be:
RunCommand acCmdDeleteRecord
However, I suspect this will still strike the same bug in this
version/patch.

--
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.

"dicej" <(E-Mail Removed)> wrote in message
news:632D10DA-3021-4D0A-B661-(E-Mail Removed)...
>I created my database in Access 2000 and my company recently upgraded to
> 2002. Certain people are still using 2000 in my organization however so I
> don't want to convert my db yet.
>
> Problem: I have a button on a form that the button wizard set up to
> delete
> a record. Previously it worked fine.
>
> While it still deletes the active record on my form, it now also gives an
> error message that says "No current record." This appears after the
> record
> is deleted.
>
> The VBA code that the wizard created is:
> DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
> DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
>
> I know those numbers refer to Access 95 commands but I don't know what
> they
> are. I still haven't figured out VBA very well...
>
> Curiously, if I select Delete Record from the menu, the error message
> doesn't appear so the code is not the same.
>
> How can I stop that error message from appearing?
> Thanks
>
>



 
Reply With Quote
 
=?Utf-8?B?ZGljZWo=?=
Guest
Posts: n/a
 
      25th Feb 2005
Thanks! That worked great. I had tried playing with the command and using
the newer RunCommand but it still generated the error.

But your code fixed the problem.



"Allen Browne" wrote:

> This is a known problem with Access 2002 SP3. This particular version/patch
> reports the "No Current Record" error immediately after the deletion, and
> then sorts itself out again quickly.
>
> Temporarily comment out the error handler, and get the actual number for the
> error. Then change the error handling part of the routine so it just ignores
> this error, i.e.:
> If Err.Number <> xxxx Then
> MsgBox ...
> End If
>
> What the wizard code does is fire off the 9th item on the Edit menu in A95
> (the first record is zero), which is Select Record. Then it fires the 7th
> item on the Edit menu, which is the Delete.
>
> A better way to code this would be:
> RunCommand acCmdDeleteRecord
> However, I suspect this will still strike the same bug in this
> version/patch.
>
> --
> 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.
>
> "dicej" <(E-Mail Removed)> wrote in message
> news:632D10DA-3021-4D0A-B661-(E-Mail Removed)...
> >I created my database in Access 2000 and my company recently upgraded to
> > 2002. Certain people are still using 2000 in my organization however so I
> > don't want to convert my db yet.
> >
> > Problem: I have a button on a form that the button wizard set up to
> > delete
> > a record. Previously it worked fine.
> >
> > While it still deletes the active record on my form, it now also gives an
> > error message that says "No current record." This appears after the
> > record
> > is deleted.
> >
> > The VBA code that the wizard created is:
> > DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
> > DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
> >
> > I know those numbers refer to Access 95 commands but I don't know what
> > they
> > are. I still haven't figured out VBA very well...
> >
> > Curiously, if I select Delete Record from the menu, the error message
> > doesn't appear so the code is not the same.
> >
> > How can I stop that error message from appearing?
> > Thanks
> >
> >

>
>
>

 
Reply With Quote
 
=?Utf-8?B?QXJjaA==?=
Guest
Posts: n/a
 
      13th Sep 2005
I am trying to use code containing acCmdDeleteRecord, with a command as in
the post "creating FORM delete button". I get error 3709, "the search key
was not found in any record". The appropriate record is deleted ok, but I
cannot persuade Access 2002 to quit issuing the error message. I tried
blanking it out with your code below, but I need more details on the MsgBox
part. Obviously, I am not a real programmer.


"Allen Browne" wrote:

> This is a known problem with Access 2002 SP3. This particular version/patch
> reports the "No Current Record" error immediately after the deletion, and
> then sorts itself out again quickly.
>
> Temporarily comment out the error handler, and get the actual number for the
> error. Then change the error handling part of the routine so it just ignores
> this error, i.e.:
> If Err.Number <> xxxx Then
> MsgBox ...
> End If
>
> What the wizard code does is fire off the 9th item on the Edit menu in A95
> (the first record is zero), which is Select Record. Then it fires the 7th
> item on the Edit menu, which is the Delete.
>
> A better way to code this would be:
> RunCommand acCmdDeleteRecord
> However, I suspect this will still strike the same bug in this
> version/patch.
>
> --
> 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.
>
> "dicej" <(E-Mail Removed)> wrote in message
> news:632D10DA-3021-4D0A-B661-(E-Mail Removed)...
> >I created my database in Access 2000 and my company recently upgraded to
> > 2002. Certain people are still using 2000 in my organization however so I
> > don't want to convert my db yet.
> >
> > Problem: I have a button on a form that the button wizard set up to
> > delete
> > a record. Previously it worked fine.
> >
> > While it still deletes the active record on my form, it now also gives an
> > error message that says "No current record." This appears after the
> > record
> > is deleted.
> >
> > The VBA code that the wizard created is:
> > DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
> > DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
> >
> > I know those numbers refer to Access 95 commands but I don't know what
> > they
> > are. I still haven't figured out VBA very well...
> >
> > Curiously, if I select Delete Record from the menu, the error message
> > doesn't appear so the code is not the same.
> >
> > How can I stop that error message from appearing?
> > Thanks
> >
> >

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete record in subform using command button Bart Microsoft Access 2 2nd Jul 2009 03:51 PM
Re: Delete Record from Command Button Vincent Verheul Microsoft Access Form Coding 3 12th Sep 2008 08:45 PM
Creating a 'Delete Record' command button. ctB Microsoft Access 3 21st Jun 2007 06:07 PM
Help with using command button to delete a record from a table Zeunasc Microsoft Access Form Coding 3 1st Mar 2007 03:03 PM
How to delete one record at a time using command button? =?Utf-8?B?U2FtIEt1bw==?= Microsoft Access Forms 6 8th Apr 2005 12:11 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:16 AM.