Function FillBlanks()
On Error GoTo Err_Test
Dim dbstest As Database
Dim rsttest As Recordset
Dim strColumnName As String
Dim TableName As String
Dim ColumnName As String
TableName = "tbl_Address" 'Replace the Table Name between the quotations
ColumnName = "column_State" 'Replace the Column Name between the quotations
strColumnName = "str" & (ColumnName)
Set dbstest = CurrentDb
Set rsttest = dbstest.OpenRecordset(TableName) 'TableName is the name of the table being modified
rsttest.MoveFirst
strOI = rsttest.Fields(ColumnName).Value
Do
If (rsttest.Fields(ColumnName).Value) = strColumnName Then ' ColumnName is the name of the column being updated
GoTo Line1
Else
If IsNull(rsttest.Fields(ColumnName).Value) Then
rsttest.Edit
rsttest.Fields(ColumnName).Value = strColumnName
rsttest.Update
ElseIf rsttest.Fields(ColumnName).Value <> strColumnName Then
strColumnName = rsttest.Fields(ColumnName).Value
End If
End If
Line1: rsttest.MoveNext
Loop Until rsttest.EOF
rsttest.MoveFirst
rsttest.Close
dbstest.Close
Exit Function
Err_Test:
MsgBox Err.Description & " " & Err.Number
Exit Function
End Function