Thanks for this suggestion. I was not able to get it to work for me but I did find a solution if anyone else needs it.
In my query, I used an IIF statement and a nested subquery.
SELECT Group_Tests1.Group_test_id, IIf([component_code0] In (Select ID from [qselreportablestohis]),[component_code0]) AS code0, IIf([component_code1] In (Select ID from [qselreportablestohis]),[component_code1]) AS code1, IIf([component_code2] In (Select ID from [qselreportablestohis]),[component_code2]) AS code2, IIf([component_code3] In (Select ID from [qselreportablestohis]),[component_code3]) AS code3, IIf([component_code4] In (Select ID from [qselreportablestohis]),[component_code4]) AS code4
and so on for 0-39 fields.
Thanks for everyone's input.