Cmd Button Not Functioning Correctly (1 Viewer)

quest4

Registered User.
Local time
Today, 01:16
Joined
Oct 12, 2004
Messages
246
Good morning, I have a form and on the form I have a cmdButton for deleting reports that have been entered, but it is not functioning correctly. Along with delete the report, especially the last report, it creates a new record as well. Here is the code for the cmdButton:
Private Sub btnDeleteRecord_Click()
On Error GoTo Err_btnDeleteRecord_Click
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
Exit_btnDeleteRecord_Click:
Exit Sub
Err_btnDeleteRecord_Click:
MsgBox Err.Description
Resume Exit_btnDeleteRecord_Click
End Sub
What is wrong with this code and why is it creating a new record after deleting? Like lets say I delete record 50, the dang thing goes and creates 51 and is sitting there waiting for data to be entered. Thank you for any assistance.:eek::mad:
 

missinglinq

AWF VIP
Local time
Today, 01:16
Joined
Jun 20, 2003
Messages
6,420
I assume when you keep speaking of deleting "reports" you actually mean to say records, since this is what your code does. Normal behavior when deleting records is for the focus to then be set on the next record. If you delete the last record, and AllowAdditions is set to Yes, you'll end up on a new record. If you have 50 records and delete record 10, you'll end up on record 11.
 

quest4

Registered User.
Local time
Today, 01:16
Joined
Oct 12, 2004
Messages
246
Thanks for the response. I added a new line, DoCmd.GoToRecord , , acFirst and now it works great.
 

Users who are viewing this thread

Top Bottom