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!

deleting record opens new one

Status
Not open for further replies.

3699wat

Technical User
Sep 30, 2002
28
US
I am trying to help out someone with a problem
The person has a form with a listbox. Clicking on an option in the listbox opens a second form with info on that item. The second form has a delete button to allow user to delete that same record and requery the list. Everything goes fine but for some reason a new record a created each time one is deleted.
Here's the code behind the delete button

'Delete record
Private Sub cmdDelete_Click()
On Error GoTo Err_cmdDelete_Click

Dim UserResponse As Integer

DoCmd.SetWarnings False
DoCmd.SetWarnings False

UserResponse = msgbox("Are you sure you wish to delete the current record?", vbYesNo, "Delete?")
If UserResponse = vbYes Then
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
DoCmd.Close
DoCmd.OpenForm "frmPatient"
DoCmd.Restore
DoCmd.Requery
End If

DoCmd.SetWarnings True

Exit_cmdDelete_Click:
Exit Sub
Err_cmdDelete_Click:
msgbox Err.Description
Resume Exit_cmdDelete_Click

End Sub

Any idea what's wrong or missing???
 
your error is in these two lines of code...

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

I believe one is delete, and one is new... look into using a recordset or an action query instead of docmd's...

you might have more control that way...

--James
junior1544@jmjpc.net
Life is change. To deny change is to deny life.
 
As far as I know those codes are standard with a delete record command button. Removing one of these lines just disable the delete action.
Any other suggestions
 
how about using an action query?
--James junior1544@jmjpc.net
Life is change. To deny change is to deny life.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top