but you are using 2 diferant recordsets.
in the first recordset, you are retunring records where the DetailProductID is equal to 1, so the first if statement is true.
in the second recordset, you are returning records where the DetailProductID is equal to 2, so again, the if statement is true.