Private Sub DeleteComponent_Click()
Dim strTableName As String
strTableName = NewComponentName.Value 'Value from a combobox
DoCmd.DeleteObject acTable, strTableName
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdDeleteRecord
NewComponentName.Requery
NewComponentName.SetFocus
End Sub
When I use this code to delete a table (referred to by the combobox) and a record with the same name in a table called ComponentTypes, it deletes the wrong record in the table. What am I doing wrong? It deletes the table ok but not the correct record.
Dim strTableName As String
strTableName = NewComponentName.Value 'Value from a combobox
DoCmd.DeleteObject acTable, strTableName
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdDeleteRecord
NewComponentName.Requery
NewComponentName.SetFocus
End Sub
When I use this code to delete a table (referred to by the combobox) and a record with the same name in a table called ComponentTypes, it deletes the wrong record in the table. What am I doing wrong? It deletes the table ok but not the correct record.