I again would like to say hello to anyone out there willing to look at my code. What it is supposed to do is delete a specific name out of a table once executed. It works, however, it only deletes the 1'st value in the field and not the one specified. I know that I can delete the data by using a form but I would like to be able to do it from the parent form instead. If anyone has any ideas they will all be greatly appreciated.
Thanks,
Tofias1
Private Sub Delete_Name_Click()
Dim stranswer As String
Dim rst As DAO.Recordset
stranswer = InputBox("Please Enter the Name which you would like to delete."
If stranswer = Names.Value Then
Set rst = CurrentDb.OpenRecordset("tblNames", dbOpenDynaset)
With rst
.Delete
DeleteRecord = fldNames
End With
rst.Close
stDocName = "Table2" 'opens form and closes form to reset the list box.
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
stDocName = "Table2"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
End Sub
Thanks,
Tofias1
Private Sub Delete_Name_Click()
Dim stranswer As String
Dim rst As DAO.Recordset
stranswer = InputBox("Please Enter the Name which you would like to delete."
If stranswer = Names.Value Then
Set rst = CurrentDb.OpenRecordset("tblNames", dbOpenDynaset)
With rst
.Delete
DeleteRecord = fldNames
End With
rst.Close
stDocName = "Table2" 'opens form and closes form to reset the list box.
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
stDocName = "Table2"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
End Sub