SELECT Trim([OPSR]![Resort ID]) AS [Resort ID], IIf([OPSR]![Super Type]="AVAIL",1,IIf([opsr]![Super Type]="BLOCKED",2,IIf([opsr]![Super Type]="COVID",3,IIf([opsr]![Super Type]="RETN",4,IIf([opsr]![Super Type]="STPSLE",5,IIf([opsr]![Super Type]="UTIL",6,"")))))) AS Sort, OPSR.[Super Type], [OPSR]![UCDX] & " " & "BR" AS UCDX, OPSR.[Check In Year], OPSR.Payment, Sum(IIf([OPSR]![WKX]=1,[OPSR]![CountOfSPACE#],0)) AS w1, Sum(IIf([OPSR]![WKX]=2,[OPSR]![CountOfSPACE#],0)) AS w2, Sum(IIf([OPSR]![WKX]=3,[OPSR]![CountOfSPACE#],0)) AS w3, Sum(IIf([OPSR]![WKX]=4,[OPSR]![CountOfSPACE#],0)) AS w4, Sum(IIf([OPSR]![WKX]=5,[OPSR]![CountOfSPACE#],0)) AS w5, Sum(IIf([OPSR]![WKX]=6,[OPSR]![CountOfSPACE#],0)) AS w6, Sum(IIf([OPSR]![WKX]=7,[OPSR]![CountOfSPACE#],0)) AS w7, Sum(IIf([OPSR]![WKX]=8,[OPSR]![CountOfSPACE#],0)) AS w8, Sum(IIf([OPSR]![WKX]=9,[OPSR]![CountOfSPACE#],0)) AS w9, Sum(IIf([OPSR]![WKX]=10,[OPSR]![CountOfSPACE#],0)) AS w10, Sum(IIf([OPSR]![WKX]=11,[OPSR]![CountOfSPACE#],0)) AS w11, Sum(IIf([OPSR]![WKX]=12,[OPSR]![CountOfSPACE#],0)) AS w12, Sum(IIf([OPSR]![WKX]=13,[OPSR]![CountOfSPACE#],0)) AS w13, Sum(IIf([OPSR]![WKX]=14,[OPSR]![CountOfSPACE#],0)) AS w14, Sum(IIf([OPSR]![WKX]=15,[OPSR]![CountOfSPACE#],0)) AS w15, Sum(IIf([OPSR]![WKX]=16,[OPSR]![CountOfSPACE#],0)) AS w16, Sum(IIf([OPSR]![WKX]=17,[OPSR]![CountOfSPACE#],0)) AS w17, Sum(IIf([OPSR]![WKX]=18,[OPSR]![CountOfSPACE#],0)) AS w18, Sum(IIf([OPSR]![WKX]=19,[OPSR]![CountOfSPACE#],0)) AS w19, Sum(IIf([OPSR]![WKX]=20,[OPSR]![CountOfSPACE#],0)) AS w20, Sum(IIf([OPSR]![WKX]=21,[OPSR]![CountOfSPACE#],0)) AS w21, Sum(IIf([OPSR]![WKX]=22,[OPSR]![CountOfSPACE#],0)) AS w22, Sum(IIf([OPSR]![WKX]=23,[OPSR]![CountOfSPACE#],0)) AS w23, Sum(IIf([OPSR]![WKX]=24,[OPSR]![CountOfSPACE#],0)) AS w24, Sum(IIf([OPSR]![WKX]=25,[OPSR]![CountOfSPACE#],0)) AS w25, Sum(IIf([OPSR]![WKX]=26,[OPSR]![CountOfSPACE#],0)) AS w26, Sum(IIf([OPSR]![WKX]=27,[OPSR]![CountOfSPACE#],0)) AS w27, Sum(IIf([OPSR]![WKX]=28,[OPSR]![CountOfSPACE#],0)) AS w28, Sum(IIf([OPSR]![WKX]=29,[OPSR]![CountOfSPACE#],0)) AS w29, Sum(IIf([OPSR]![WKX]=30,[OPSR]![CountOfSPACE#],0)) AS w30, Sum(IIf([OPSR]![WKX]=31,[OPSR]![CountOfSPACE#],0)) AS w31, Sum(IIf([OPSR]![WKX]=32,[OPSR]![CountOfSPACE#],0)) AS w32, Sum(IIf([OPSR]![WKX]=33,[OPSR]![CountOfSPACE#],0)) AS w33, Sum(IIf([OPSR]![WKX]=34,[OPSR]![CountOfSPACE#],0)) AS w34, Sum(IIf([OPSR]![WKX]=35,[OPSR]![CountOfSPACE#],0)) AS w35, Sum(IIf([OPSR]![WKX]=36,[OPSR]![CountOfSPACE#],0)) AS w36, Sum(IIf([OPSR]![WKX]=37,[OPSR]![CountOfSPACE#],0)) AS w37, Sum(IIf([OPSR]![WKX]=38,[OPSR]![CountOfSPACE#],0)) AS w38, Sum(IIf([OPSR]![WKX]=39,[OPSR]![CountOfSPACE#],0)) AS w39, Sum(IIf([OPSR]![WKX]=40,[OPSR]![CountOfSPACE#],0)) AS w40, Sum(IIf([OPSR]![WKX]=41,[OPSR]![CountOfSPACE#],0)) AS w41, Sum(IIf([OPSR]![WKX]=42,[OPSR]![CountOfSPACE#],0)) AS w42, Sum(IIf([OPSR]![WKX]=43,[OPSR]![CountOfSPACE#],0)) AS w43, Sum(IIf([OPSR]![WKX]=44,[OPSR]![CountOfSPACE#],0)) AS w44, Sum(IIf([OPSR]![WKX]=45,[OPSR]![CountOfSPACE#],0)) AS w45, Sum(IIf([OPSR]![WKX]=46,[OPSR]![CountOfSPACE#],0)) AS w46, Sum(IIf([OPSR]![WKX]=47,[OPSR]![CountOfSPACE#],0)) AS w47, Sum(IIf([OPSR]![WKX]=48,[OPSR]![CountOfSPACE#],0)) AS w48, Sum(IIf([OPSR]![WKX]=49,[OPSR]![CountOfSPACE#],0)) AS w49, Sum(IIf([OPSR]![WKX]=50,[OPSR]![CountOfSPACE#],0)) AS w50, Sum(IIf([OPSR]![WKX]=51,[OPSR]![CountOfSPACE#],0)) AS w51, Sum(IIf([OPSR]![WKX]=52,[OPSR]![CountOfSPACE#],0)) AS w52, Sum(IIf([OPSR]![WKX]=53,[OPSR]![CountOfSPACE#],0)) AS w53, Sum([OPSR]![CountOfSPACE#]) AS TOT INTO [Output]
FROM OPSR
WHERE (((OPSR.RESX)='"& rs.Fields("RCODE")&"'"))
GROUP BY Trim([OPSR]![Resort ID]), IIf([OPSR]![Super Type]="AVAIL",1,IIf([opsr]![Super Type]="BLOCKED",2,IIf([opsr]![Super Type]="COVID",3,IIf([opsr]![Super Type]="RETN",4,IIf([opsr]![Super Type]="STPSLE",5,IIf([opsr]![Super Type]="UTIL",6,"")))))), OPSR.[Super Type], [OPSR]![UCDX] & " " & "BR", OPSR.[Check In Year], OPSR.Payment
HAVING (((OPSR.[Check In Year])=[Forms]![Form1]![Text124] Or (OPSR.[Check In Year])=[Forms]![Form1]![Text126] Or (OPSR.[Check In Year])=[Forms]![Form1]![Text128] Or (OPSR.[Check In Year])=[Forms]![Form1]![Text132] Or (OPSR.[Check In Year])=[Forms]![Form1]![Text130] Or (OPSR.[Check In Year])=[Forms]![Form1]![Text134] Or (OPSR.[Check In Year])=[Forms]![Form1]![Text138] Or (OPSR.[Check In Year])=[Forms]![Form1]![Text142] Or (OPSR.[Check In Year])=[Forms]![Form1]![Text140] Or (OPSR.[Check In Year])=[Forms]![Form1]![Text136] Or (OPSR.[Check In Year])=[Forms]![Form1]![Text144] Or (OPSR.[Check In Year])=[Forms]![Form1]![Text146]));