Codeunit to pick out non matching fields


I need to write a codeunit that will pick out non matching fields. The one of the fields has a datatype of code the other is an option and it has a one to many relationship( 1 option to many codes). I need this codeunit to find all records where these fields don't match and trigger a Boolean field to true so then the client can filter on it. 

This is what I have written so far but it doesn't seem to trigger the Boolean field to true and I am unsure why.. 

IF Table1.GET(Table2."Code Field") THEN BEGIN
IF Table2.Option<> Table1.Option THEN BEGIN
Table1."Boolean" := TRUE;
Table1.SETRANGE("Boolean", TRUE);

Table1 is bespoke for the codes to show which option goes with them and Table2 is general table which is where the data is kept for each record..

Please excuse me I am still a beginner.. 

Thank youuu!