Psycholicon
Registered User.
- Local time
- Today, 13:34
- Joined
- Aug 14, 2007
- Messages
- 33
Hi, I have a command button that has to do several things at once. All of the code works out well except for one DELETE statement. It runs without error, but won't delete the records. The command button is on the form ReleaseDCN, and the control referred to is a drop-down list box. I only want it to delete from the table Drawing Link, but part of the criteria comes from a relation to another table. When I copy and paste this into a select query it works fine. The only difference there is that in the query it says explicit =Deletion at the end, but in VB I made it a string to clean things up (I thought). Please tell me what I'm doing wrong.
strField = "Deletion"
strSQL = "DELETE [Drawing Link].* FROM [Drawing Link] INNER JOIN [DCN Details] ON [Drawing Link].[Drawing Number] = [DCN Details].[Drawing Number] WHERE ((([DCN Details].[DCN Number]) = [Forms]![ReleaseDCN]![ReleasedDCN]) And (([DCN Details].[Change Type]) = '" & strField & "'))"
Debug.Print strSQL
DoCmd.RunSQL strSQL
strField = "Deletion"
strSQL = "DELETE [Drawing Link].* FROM [Drawing Link] INNER JOIN [DCN Details] ON [Drawing Link].[Drawing Number] = [DCN Details].[Drawing Number] WHERE ((([DCN Details].[DCN Number]) = [Forms]![ReleaseDCN]![ReleasedDCN]) And (([DCN Details].[Change Type]) = '" & strField & "'))"
Debug.Print strSQL
DoCmd.RunSQL strSQL