Deleting a record in a list box and combo box.

J

James

I have a combo box that has the catagory name (don't pay attention to the
txt...it's a combo box) for a group of products. I also have a list box to
display all of the products for that catagory.

I would like to be able to delete items in the combo and list boxes from a
command button on the forms, but I only know how to open a form and delete
the record. So I have this code below, but I get an error message that says,
"No current record" after it completes the delete procedure. Then the
docmd.close does not work. Is there a way to delete the items from a command
button on the form, or a way to get rid of this error.

Thank you!

-----------start code-----------------
If Me.txtCatagoryName.ListCount > 1 Then
Dim strWhere As String

strWhere = "CatagoryID = " & Me!txtCatagoryName.Column(0)
DoCmd.OpenForm "frmCatagory", , , strWhere
DoCmd.RunCommand acCmdDeleteRecord
DoCmd.Close "frmCatagory"
Me.txtCatagoryName.Requery
Me.lstProduct.Requery
Else
MsgBox "You must select a Catagory before removing."
End If
------------end code----------------
 
Top