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???
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???