title: Replacing null values for multiple columns in a table with a constant value
body: <p>I am trying to run a script that replaces all null values in a table with a constant value in MS Access 2007. I am fully aware that this can be done using an update query. But the requirement that I need to do that for all columns in one click. I figured that find/replace can do this, but still I would rather minimize any manual work in the process. </p>
  
  <p>I tried using this code but when I try to run it, it just doesn't do anything. It doesn't even trigger an error. </p>
  
  <pre><code>Sub replacingnulls()
  
  Dim dbs As DAO.Database
  Dim rs As DAO.Recordset
  Dim fld As DAO.Field
  
  Set dbs = CurrentDb
  Set rs = dbs.OpenRecordset("testtable", dbOpenTable)
  
  If Not (rs.EOF And rs.BOF) Then
      rs.MoveFirst
      Do Until rs.EOF = True
              rs.Edit
  
          For Each fld In rs.Fields
  
              If IsNull(fld.Value) Then
                  fld.Value = 555
  
              End If
          Next fld
          rs.MoveNext
    Loop
  Else
      MsgBox ("There are no records")
  End If
  
  rs.Close
  
  End Sub
  </code></pre>