deletion of records

L

Lauren B

I have a list of names and I wish to give my users the ability to add to and
delete from this list. The deletion process is done through a separate form
the contains a combo box of all names. The user selects the one they want
to delete and hit the "delete" command button. However, when this button is
clicked, the top record (regarless of the one actually selected by the user)
is deleted. Also, it leaves #DELETED in its place. The code behind my
delete button is as follows:

Private Sub Deleteresp_Click()
On Error GoTo Err_Delete_Click


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

Exit_Deleteresp_Click:
Exit Sub

Err_Deleteresp_Click:
MsgBox Err.Description
Resume Exit_Delete_Click

End Sub

How can I fix this problem?

Thank you in advance for any assistance.

LB
 
R

rowiga

I'm not sure how your form is setup but if you're running a delete statement
through a delete query or just a SQL statement you need to reference the
choice in the combo box. Such as:

Private Sub cboDeleteSelection_AfterUpdate()
DoCmd.RunSQL "DELETE from MyTable WHERE MyTable.MyID =
Forms![MyForm]![cboDeleteSelection]"
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top