I have the following code...
Which works fine, but the DoCmd.RunCommand... line runs an Access delete function which (for reasons which entirely escape me) immediately displays the next record, pops up another delete confirm dialog but actually deletes the previously displayed record! Slightly confusing for the user, very confusing for this very-newbie programmer! How can I prevent the Access delete function confirmation dialog from appearing and prevent the displayed record from incrementing?
Any help much appreciated.
Mike
Code:
'---------------------------------------------------------------------------------------------
'Deletes the current specimen record
'---------------------------------------------------------------------------------------------
Private Sub cmd_DeleteThisSpecimen_Click()
On Error GoTo Err_cmd_DeleteThisSpecimen_Click
Dim StrPromptText As String, strTitleText As String
StrPromptText = "Confirm delete this record?"
strTitleText = "Delete Record"
If MsgBox(StrPromptText, vbOKCancel + vbExclamation, strTitleText) = vbOK Then
DoCmd.RunCommand acCmdDeleteRecord 'delete the current record
Else
'do nothing
End If
Exit_cmd_DeleteThisSpecimen_Click:
Exit Sub
Err_cmd_DeleteThisSpecimen_Click:
MsgBox Err.Description
Resume Exit_cmd_DeleteThisSpecimen_Click
End Sub
Which works fine, but the DoCmd.RunCommand... line runs an Access delete function which (for reasons which entirely escape me) immediately displays the next record, pops up another delete confirm dialog but actually deletes the previously displayed record! Slightly confusing for the user, very confusing for this very-newbie programmer! How can I prevent the Access delete function confirmation dialog from appearing and prevent the displayed record from incrementing?
Any help much appreciated.
Mike