Set db = CurrentDb()
Sql1 = "SELECT [col_4],[col_1]From[Initial_Query] WHERE ([col_4]<>'NA');"
Set rs = db.OpenRecordset(Sql1, dbOpenSnapshot)
If rs.RecordCount > 0 Then
Sql1 = "Update [New_Query]SET[New_Query].[col_4]=" & Sql1 & "WHERE [Initial_Query].[col_1]=[New_Query].[col_1];"
db.Execute Sql1, dbfilonerror
End If
rs.Close
Sql2 = "Select[col_4],[col_3],[col_1]FROM [Initial_Query]WHERE([col_4]='NA');"
Set rs = db.OpenRecordset(Sql2, dbOpenSnapshot)
If rs.RecordCount > 0 Then
Sql3="SELECT Count(Initial_Query.col_3) AS CountOfcol_3, New_Query.col3" & _
"FROM New_Query INNER JOIN Initial_Query ON New_Query.col_1= Initial_Query.col_1" & _
"GROUP BY New_Query.col3;"
db.Execute Sql2, dbfilonerror
For rs.CountOfcol_3 = 1 Then
Set rs = db.OpenRecordset(Sql2,dbOpenSnapshot)
Sql2 = "Update [New_Query]SET[New_Query].[col_4]="& Sql2 & "WHERE [Initial_Query].[col_1]=[New_Query].[col_1];"
db.Execute Sql2, dbfilonerror
For rs.CountOfcol_3 <> 1 Then
Ser rs = db.OpenRecordset(Sql2,dbOpenSnapshot)
Sql2 = ""Update [New_Query]SET[New_Query].[col_4]=[New_Query].[col_3] WHERE [Initial_Query].[col_1]=[New_Query].[col_1];"
db.Exeute Sql2, dbfilonerror
End If