GotoRecord after delete

PaulA

Registered User.
Local time
Today, 13:48
Joined
Jul 17, 2001
Messages
416
Hi, all--

I have a standard command button on a form to delete the current record. After this is done, I want to go to the previous record (assuming we're not at the first record).

I have tried various docmd.gotorecord statements in the VBA but have various problems.

When using acPrevious, I get a "Can't go to specific record", even if the deleted record was the last record.

When I use the acLast, the form goes to the first record. In fact, I either get the "Can't go to..." or the form goes to the first record no matter which "ac" I use.

My code is as follows (and it's very basic):

DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

Me.Requery
DoCmd.GoToRecord , , acPrevious (or acLast)

Any suggestions?

Thanks.
 
Change the code to be:

DoCmd.RunCommand acCmdDeleteRecord
DoCmd.GoToRecord , , acPrevious
 
PaulA said:
My code is as follows (and it's very basic):

DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

First off, it's not "basic"; it's defunct.

Those two lines are now replaced with:

Code:
DoCmd.RunCommand acCmdDeleteRecord

Can you make this change an post an example and I'll have a look at it?
 
I forgot to mention that I am using A97 and the command button was created using the wizard.
 

Users who are viewing this thread

Back
Top Bottom