Hi,
I am trying to delete a selected record with the following code:
For records with values for all the variables there is no problem.
But there are records in the table dbo_Conversie_lokatie and in the Listbox with null values.
These records will not be deleted with the code.
If Me![Listbox].Column(4) is null, there is the message: "you are about to delete 0 rows from the specified table". (it should be 1 row).
If Me![Listbox].Column(6) is null, there is no error message. From the Docmd it goes directly to End sub but does not delete the record.
How can I change the code that the null values are deleted as well?
I tried soemthing with IsNull, but it does not work either. I changed the sSQL:
When only [PROVINCIE_CODE] and (Me![Listbox].Column(4)) is null now it tries to delete 0 rows again, while it should be 1 row.
I hope somebode can help me!
Thanks,
Tep
I am trying to delete a selected record with the following code:
Code:
Private Sub BtDelRecord_Click()
On Error GoTo Err_cmdSaveRecord_Click
Dim strSQL As String
strSQL = "DELETE * FROM [dbo_Conversie_lokatie] WHERE [dbo_Conversie_lokatie].[CONVERSIEPROG_NAAM] = '" & Me![Listbox].Column(0) & "' AND [dbo_Conversie_lokatie].[PLAATS_EXTERN] = '" & Me![Listbox].Column(1) & "' AND [dbo_Conversie_lokatie].[LAND_CODE] = '" & Me![Listbox].Column(2) & "' AND [dbo_Conversie_lokatie].[PROVINCIE_CODE] = '" & Me![Listbox].Column(4) & "' AND [dbo_Conversie_lokatie].[LOKATIE_NUMMER] = " & Me![Listbox].Column(6) & " "
DoCmd.RunSQL strSQL
Me![Listbox].Requery
Exit_cmdSaveRecord_Click:
Err_cmdSaveRecord_Click:
Exit Sub
MsgBox Err.Description
Resume Exit_cmdSaveRecord_Click
End Sub
But there are records in the table dbo_Conversie_lokatie and in the Listbox with null values.
These records will not be deleted with the code.
If Me![Listbox].Column(4) is null, there is the message: "you are about to delete 0 rows from the specified table". (it should be 1 row).
If Me![Listbox].Column(6) is null, there is no error message. From the Docmd it goes directly to End sub but does not delete the record.
How can I change the code that the null values are deleted as well?
I tried soemthing with IsNull, but it does not work either. I changed the sSQL:
Code:
strSQL = "DELETE * FROM [dbo_Conversie_lokatie] WHERE [dbo_Conversie_lokatie].[CONVERSIEPROG_NAAM] = '" & Me![Listbox].Column(0) & "' AND [dbo_Conversie_lokatie].[PLAATS_EXTERN] = '" & Me![Listbox].Column(1) & "' AND [dbo_Conversie_lokatie].[LAND_CODE] = '" & Me![Listbox].Column(2) & "' AND IsNull ([dbo_Conversie_lokatie].[PROVINCIE_CODE]) = '" & IsNull ((Me![Listbox].Column(4))) & "' AND [dbo_Conversie_lokatie].[LOKATIE_NUMMER] = " & Me![Listbox].Column(6) & " "
I hope somebode can help me!
Thanks,
Tep