Hi!
I have a delete code that runs on the OnClick of a command button. For some reason, in my computer, the application is freezes and then closes when i am running this code...
I have no idea of what could be causining this. I tried the application at my home computer and there if worked fine.
I am using Access 2000 and the delete routine is the following:
Dim qdfDelete As QueryDef
Dim strDelete As String
Dim rstCAPAs As DAO.Recordset
Set rstCAPAs = CurrentDb.OpenRecordset("SELECT [Corrective and Preventive Actions].InvestigationNo, " & _
"[Corrective and Preventive Actions].ActionCode, [Corrective and Preventive Actions].ActionNo " & _
"From [Corrective and Preventive Actions] " & _
"WHERE ((([Corrective and Preventive Actions].InvestigationNo)= """ & [Forms]![sfrmCorrectiveActions]![txtInvestigationNo] & """) AND (([Corrective and Preventive Actions].ActionCode)= """ & [Forms]![sfrmCorrectiveActions]![txtActionCode] & """) AND (([Corrective and Preventive Actions].ActionNo)=" & [Forms]![sfrmCorrectiveActions]![txtActionNo] & "));")
If rstCAPAs.RecordCount <> 0 Then
strDelete = "DELETE * " & _
"FROM [Corrective and Preventive Actions] " & _
"WHERE ((([Corrective and Preventive Actions].InvestigationNo)=""" & [Forms]![sfrmCorrectiveActions]![txtInvestigationNo] & """) AND (([Corrective and Preventive Actions].ActionCode)=""" & [Forms]![sfrmCorrectiveActions]![txtActionCode] & """) AND (([Corrective and Preventive Actions].ActionNo)=" & [Forms]![sfrmCorrectiveActions]![txtActionNo] & "));"
'Create new query definition
Set qdfDelete = CurrentDb.CreateQueryDef("", strDelete)
'Execute delete query
qdfDelete.Execute
[Forms]![sfrmCorrectiveActions].Requery
End If
PLEASE HELP ME!!
Yolanda
I have a delete code that runs on the OnClick of a command button. For some reason, in my computer, the application is freezes and then closes when i am running this code...
I have no idea of what could be causining this. I tried the application at my home computer and there if worked fine.
I am using Access 2000 and the delete routine is the following:
Dim qdfDelete As QueryDef
Dim strDelete As String
Dim rstCAPAs As DAO.Recordset
Set rstCAPAs = CurrentDb.OpenRecordset("SELECT [Corrective and Preventive Actions].InvestigationNo, " & _
"[Corrective and Preventive Actions].ActionCode, [Corrective and Preventive Actions].ActionNo " & _
"From [Corrective and Preventive Actions] " & _
"WHERE ((([Corrective and Preventive Actions].InvestigationNo)= """ & [Forms]![sfrmCorrectiveActions]![txtInvestigationNo] & """) AND (([Corrective and Preventive Actions].ActionCode)= """ & [Forms]![sfrmCorrectiveActions]![txtActionCode] & """) AND (([Corrective and Preventive Actions].ActionNo)=" & [Forms]![sfrmCorrectiveActions]![txtActionNo] & "));")
If rstCAPAs.RecordCount <> 0 Then
strDelete = "DELETE * " & _
"FROM [Corrective and Preventive Actions] " & _
"WHERE ((([Corrective and Preventive Actions].InvestigationNo)=""" & [Forms]![sfrmCorrectiveActions]![txtInvestigationNo] & """) AND (([Corrective and Preventive Actions].ActionCode)=""" & [Forms]![sfrmCorrectiveActions]![txtActionCode] & """) AND (([Corrective and Preventive Actions].ActionNo)=" & [Forms]![sfrmCorrectiveActions]![txtActionNo] & "));"
'Create new query definition
Set qdfDelete = CurrentDb.CreateQueryDef("", strDelete)
'Execute delete query
qdfDelete.Execute
[Forms]![sfrmCorrectiveActions].Requery
End If
PLEASE HELP ME!!
Yolanda