Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Q: Deleting record problem...

Status
Not open for further replies.

mikeg8

Technical User
Sep 11, 2003
32
GB
I have the following code...

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
 
Put in the beginning of your event procedure

DoCmd.SetWarnings False

and at the end

DoCmd.SetWarnings True
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top