1

MS-Access 2003 で次のクエリを実行しましたが、問題なく動作します。

SELECT tblDiscounts.DiscountID, tblDiscounts.DiscountPercent, tblDiscounts.DiscountName, tblDiscounts.DiscountDescription
FROM tblDiscounts, qryPropertyPeriodRate_Count_Nested
WHERE (tblDiscounts.DiscountID) = IIf ([qryPropertyPeriodRate_Count_Nested].[CountOfWeeks]=1,1,IIf([qryPropertyPeriodRate_Count_Nested].[CountOfWeeks]=2,2,IIf([qryPropertyPeriodRate_Count_Nested].[CountOfWeeks]=3,3,4)));

IIf 関数を Switch 関数に置き換えたいのですが、何を試してもうまくいきませんでした。私の最善のアプローチは次のとおりです。

SELECT tblDiscounts.DiscountID, tblDiscounts.DiscountPercent, tblDiscounts.DiscountName, tblDiscounts.DiscountDescription
FROM tblDiscounts, qryPropertyPeriodRate_Count_Nested
WHERE (((tblDiscounts.DiscountID)=SWITCH ([qryPropertyPeriodRate_Count_Nested].[CountOfWeeks]=1,1, [qryPropertyPeriodRate_Count_Nested].[CountOfWeeks]=2,2, [qryPropertyPeriodRate_Count_Nested].[CountOfWeeks]=3,3, [qryPropertyPeriodRate_Count_Nested].[CountOfWeeks]>3,4)));

しかし、私はメッセージを受け取ります

式の型の不一致

お知らせ下さい!

4

1 に答える 1

2

私が見ることができる1つの違いは[qryPropertyPeriodRate_Count_Nested].[CountOfWeeks]<1、ネストされたIIfs が返され4Switchステートメントが返される場合Nullです。基礎となるデータをチェックして、それが発生する可能性があるかどうかを確認してください。Null値が WHERE 句を台無しにする可能性があります。

于 2013-09-07T22:11:22.057 に答える