4

ユーザーが入力した開始日と今日の日付に基づいて、テーブルから情報を選択するパラメータークエリがあります。開始日のプロンプトを2回入力せずに、WHEREステートメントを使用してテーブル内の2つのフィールドを検索したいと思います。今私は持っています:

SELECT PatientSurvey.PatientID
FROM PatientSurvey
WHERE (PatientSurvey.[6MonthSurveyReturn] OR PatientSurvey.[12MonthSurveyReturn]) Between [Enter the last date checked for:] And Date();

これはうまくいかないようです。しかし、私が次のことをした場合:

SELECT PatientSurvey.PatientID
FROM PatientSurvey
WHERE (PatientSurvey.[6MonthSurveyReturn]) Between [Enter the last date checked for:] And Date() OR (PatientSurvey.[12MonthSurveyReturn]) Between [Enter the last date checked for:] And Date();

次に、同じ入力を2回ユーザーに求めます。どうすればこれを防ぐことができますか?

4

1 に答える 1

4

クエリにPARAMETERS宣言を追加します。

PARAMETERS [Enter the last date checked for:] DateTime;
SELECT PatientSurvey.PatientID
FROM PatientSurvey
WHERE
       (([PatientSurvey].[6MonthSurveyReturn]) Between [Enter the last date checked for:] And Date())
    OR (([PatientSurvey].[12MonthSurveyReturn]) Between [Enter the last date checked for:] And Date());
于 2011-08-05T00:03:43.567 に答える