I am trying to update a table from another table where:
If Table1.networks = Table2.Networks then
Update Table1.Networks with Table2.Net
I am having difficulties with having table1.networks being compared to Table2
My intent is to have table2 loop through its contents to see if any rows are equal. if not then it goes to The next row in table1.networks
Code:
Private Sub funcky_Click()
Dim rU As DAO.Recordset, rU2 As DAO.Recordset
Dim Net As String
Set rU = CurrentDb.OpenRecordset("Data")
Set rU2 = CurrentDb.OpenRecordset("NetworkChange")
If rU.BOF And rU.EOF Then
rU.Close
Else
rU.MoveLast
rU.MoveFirst
rU2.MoveFirst
Do While Not rU.EOF
Do While Not rU2.EOF
If rU![Networks] = rU2![Networks] Then
Net = Not IsNull(rU2![Networks2])
Elseif rU![Networks] = "" Then
Net = ""
Else: Net = rU![Networks]
End If
Loop
rU2.MoveNext
rU.Edit
rU![Networks2] = Net
rU.Update
rU.MoveNext
Loop
End If
rU.Close
Set rU = Nothing
End Sub
Private Sub Test_Click()
Dim rU As DAO.Recordset
Set rU = CurrentDb.OpenRecordset("Data")
If rU.BOF And rU.EOF Then
rU.Close
Else
rU.MoveLast
rU.MoveFirst
Do While Not rU.EOF
rU.Edit
rU![Networks2] = Null
rU.Update
rU.MoveNext
Loop
End If
rU2.Close
Set rU2 = Nothing
rU.Close
Set rU = Nothing
End Sub