I have 3 tables
ConnectivityFile
where I have the ids for some properties
CHAINDD
where I have the hotel codes (they can be repeated) for the same properties
Export
where I want to have all the hotel codes and their ids (a join for the previous tables)
I can achieve that with the query below
query2 = "SELECT ConnectivityFile.ID as [Hotel ID], ConnectivityFile.HotelCode
FROM ConnectivityFile
INNER JOIN (SELECT DISTINCT CHAINDD.HOTELCODE as [Hotel Code] from CHAINDD) as T
ON ConnectivityFile.HotelCode = T.[Hotel Code]"
DoCmd.RunSQL "INSERT INTO Export " & query2
Now the issue I am facing is that let's say the hotel code from table CHAINDD is not present on table ConnectivityFile. I would like to point that out as "Not Connected" as the ID on the export table.
How can achieve that? I know there is the IIF statement when I have done some trial and error with no success. Where do you place the IIf statement?
Thank you very much for all your help and time