1

フォームに入力されたパラメータに基づいてクエリを作成しようとしています。ユーザーがパラメーターを入力しないことを選択した場合 (例: 開始日と終了日)、またはユーザーがパラメーターの半分のみを入力した場合 (例: ユーザーが開始日のみを入力し、終了日を入力しなかった場合、または開始日ではなく終了日)。これは私が欲しいものです:

開始日と終了日が null の場合は、すべての日付を返します。

そうでなければ、開始日が null の場合は、指定された終了日以前の日付を返します。

そうでなければ、終了日が null の場合は、指定された開始日以降の日付を返します。

そうでなければ、指定された開始日から終了日までのすべての日付を返します

私が思いついたことは、最初の真のステートメントを超えて評価されていないようで、その理由はわかりません.

IIf(IsNull([forms]![Volunteer_Hours_By_Person]![Volunteer_Hours_By_Person_Start_Date]
And [forms]![Volunteer_Hours_By_Person]![Volunteer_Hours_By_Person_End_Date]),  
[Volunteer_Date],  

IIf(IsNull([forms]![Volunteer_Hours_By_Person]![Volunteer_Hours_By_Person_Start_Date]),  
<= [forms]![Volunteer_Hours_By_Person]![Volunteer_Hours_By_Person_End_Date],  

IIf(IsNull([forms]![Volunteer_Hours_By_Person]![Volunteer_Hours_By_Person_End_Date]),  
>= [forms]![Volunteer_Hours_By_Person]![Volunteer_Hours_By_Person_Start_Date],  

(Between [forms]![Volunteer_Hours_By_Person]![Volunteer_Hours_By_Person_Start_Date] 
And [forms]![Volunteer_Hours_By_Person]![Volunteer_Hours_By_Person_End_Date]))))
4

1 に答える 1

0

とった!

WHERE (IIf(IsNull([Forms]![Volunteer_Hours_By_Person]!      [Volunteer_Hours_By_Person_Name_Selection]),(People.PID) like "*",(People.PID)=[Forms]![Volunteer_Hours_By_Person]![Volunteer_Hours_By_Person_Name_Selection]))

AND (IIf(IsNull([forms]![Volunteer_Hours_By_Person]![Volunteer_Hours_By_Person_Start_Date]) AND IsNull([forms]![Volunteer_Hours_By_Person]![Volunteer_Hours_By_Person_End_Date]),(Volunteer.Volunteer_Date) like "*",([Volunteer].[Volunteer_Date]) Between [forms]![Volunteer_Hours_By_Person]![Volunteer_Hours_By_Person_Start_Date] And [forms]![Volunteer_Hours_By_Person]![Volunteer_Hours_By_Person_End_Date]))
于 2011-04-18T00:44:14.233 に答える