I have two tables with a unique field which i use to join the tables. I'm trying to compare the tables using access queries and some vba to find the changes within the records from the two tables. The problem is that I get the first change (field) between the tables per row rather than multiple changes within a row. For instance if the field "city" and "country" changed within a row, it only identifies one of them. I would like to have a new table with all the changes within a record. I have read about using recursive methods, any help will be greatly appreciated.
Code:
Sub NetworkChange()
Dim fld As DAO.Field
DoCmd.SetWarnings False
DoCmd.OpenQuery "ALL_post_compare_test1", , acReadOnly
Set rs = CurrentDb.OpenRecordset("Modifications1")
Do Until rs.EOF = True
'Perform an edit
rs.Edit
rs![Change Field] = True
If rs("Outlet") <> rs("Old Outlet") Then
rs("Change Field") = CurrentDb.TableDefs("Modifications1").Fields(2) ['Old Outlet'];")
ElseIf rs("Business") <> rs("Old Business") Then
rs("Change Field") = CurrentDb.TableDefs("Modifications1").Fields(3).NAME
ElseIf rs("Address") <> rs("Old Address") Then
rs("Change Field") = CurrentDb.TableDefs("Modifications1").Fields(4).NAME
ElseIf rs("City") <> rs("Old City") Then
rs("Change Field") = CurrentDb.TableDefs("Modifications1").Fields(5).NAME
ElseIf rs("Prov") <> rs("Old Prov") Then
rs("Change Field") = CurrentDb.TableDefs("Modifications1").Fields(6).NAME
ElseIf rs("Pcode") <> rs("Old Pcode") Then
rs("Change Field") = CurrentDb.TableDefs("Modifications1").Fields(7).NAME
ElseIf rs("Phone") <> rs("Old Phone") Then
rs("Change Field") = CurrentDb.TableDefs("Modifications").Fields(8).NAME
Else: rs("Change Field") = "-"
End If
rs.Update
Loop
Comment