2011-08-04 39 views
2

我有一个参数查询,根据用户输入的开始日期和当前日期从我的表中选择信息。我想用WHERE语句在表格中搜索两个字段,而不是两次输入开始日期的提示。现在我有:不止一次提示用户输入相同的查询参数(MS-Access)

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(); 

然后,它会提示用户两次相同的输入。这怎么能防止?

回答

3

向您的查询添加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()); 
+0

非常感谢您的帮助! – jrubins

相关问题