Why have you linked the CodID to both the origin and the dest?
With that join in place, it will only match records where BOTH the origin and dest match the CodID... which would mean the origin and dest would have to be the same?
... also, which Flag is it you're wishing to update to True?
Currently i am using code
f is tbldataentry.origin
g is tbldataentry.dest
p = DLookup("flag", "tblCodes", "Cod_ID = " & f)
q = DLookup("flag", "tblCodes", "Cod_ID = " & g)
If (f = g) Then
MsgBox ("Origin and Destination cannot be same, Please Check")
Exit Sub
End If
If (p = -1 Or q = -1) Then
r = 1
Else
r = 0
End If