title: Inserting NULL values in a database from VBA code
body: <p>I have 3 radioButtons ("YES", "NO", "UNKNOWN") wich matches a column from my database with 3 possible values (1, 0, NULL). </p>
  
  <p>When the radioButton selected is "UNKNOWN" I want to insert a NULL value in this table (using Variant type). But when I try to run my SQL query with my ADODB connection, it returns an error.</p>
  
  <p>Is there a trick to pass NULL values in my database ? Here's a copy of my code :</p>
  
  <pre><code>Public Function setCandidature(idC As Integer, idO As Integer, nomC As String, prenomC As String, nomM As String, prenomM As String, idRegion As Integer, idUM As Integer, idDUM As Integer, nni As String, emploiC As String, repM As Integer, repA As Integer, accDisp As Integer, precAcc1 As Integer, precAcc2 As Integer)
  Dim sqlQuery As String
  Dim rs As ADODB.Recordset
  Dim repAVar As Variant, repMVar As Variant
  
  Set connect = New ADODB.Connection
  connect.Open connString
  
  If repA = -1 Then
      repAVar = Null
  Else
      repAVar = repA
  End If
  
  If repM = -1 Then
      repMVar = Null
  Else
      repMVar = repM
  End If
  
  sqlQuery = "UPDATE candidatures SET offre_ID = " &amp; idO &amp; ", candidat_Nom = " &amp; nomC &amp; ", candidat_Prenom = " &amp; prenomC &amp; ", manager_Nom = " &amp; nomM &amp; ", manager_Prenom = " &amp; prenomM &amp; ", reponse_Manager = " &amp; repMVar &amp; ", reponse_Agent = " &amp; repAVar &amp; ", region_Candidat = " &amp; idRegion &amp; _
             ", um_Candidat = " &amp; idUM &amp; ", dum_Candidat = " &amp; idDUM &amp; ", nni_Candidat = " &amp; nni &amp; ", emploi_Candidat = " &amp; emploiC &amp; ", accompagnement_Dispense = " &amp; accDisp &amp; ", accompagnement_Precision_ID = " &amp; precAcc1 &amp; ", accompagnement2_Precision_ID = " &amp; precAcc2 &amp; _
             " WHERE candidature_ID = " &amp; idC &amp; ";"
  
  rs.Open sqlQuery, connect
  End Function
  </code></pre>
  
  <p>I first pass the values that I want to be NULL as Integers containing -1.</p>