使用Access数据库中的checkbox和combobox进行查询

时间:2016-04-19 12:51:08

标签: sql ms-access checkbox combobox ms-access-2010

下午好 这是我的问题:

SELECT Reference.quote_date AS [Quote Date]
  , Reference.agent_ID AS Agent
  , Reference.ref_ID AS ReferenceID
  , Reference.ref_number AS [Ref Number]
  , Customer.title_id AS Title
  , Customer.name AS Name
  , Customer.surname AS Surname
  , Customer.postcode AS Postcode
  , Customer.telephone AS Telephone
  , Reference.location_ID AS Location
  , Reference.policy_ID AS Product
  , Reference.price AS Price
  , Reference.status_ID AS Status
  , Reference.source_ID AS Source
  , Reference.calltype_ID AS [Call Type]
  , Reference.prize_draw AS [Prize Draw]
  , Reference.Call_back_date AS [Call back date]
  , Reference.call_back AS [Call back]
  , Reference.IsCompleted AS Completed
  , Reference.comments AS Comments
FROM Customer INNER JOIN Reference 
  ON Customer.[customer_ID] = Reference.[customer_ID]
WHERE (((Reference.agent_ID)=[Forms]![Call_Back_Search1]![Combo5]) 
  AND ((Reference.Call_back_date) 
    Between [Forms]![Call_Back_Search1]![StartDateTxt] And [Forms]![Call_Back_Search1]![EndDatetxt]));

它目前显示在Call_Back_Search1表单中选择的特定条件内的所有回调: - 日期标准:开始日期:结束日期 - 并允许选择代理(Combobox05)。 我希望在查询中添加其他条件:
名为“已完成”的复选框未勾选 - 仅根据所选日期范围显示结果(保留组合框空白)
不知道我能不能问你任何建议 谢谢

1 个答案:

答案 0 :(得分:0)

我希望有人会发现我的答案很有用 代码如下:

SELECT Reference.quote_date AS [Quote Date],Reference.agent_ID AS Agent,Reference.ref_ID AS ReferenceID,Reference.ref_number AS [Ref Number],Customer.title_id AS Title,Customer.name AS Name,Customer.surname AS Surname,Customer.postcode AS Postcode,Customer.telephone AS Telephone,Reference.location_ID AS Location,Reference.policy_ID AS Product,Reference.price AS Price,Reference.status_ID AS Status,Reference.source_ID AS Source,Reference.calltype_ID AS [Call Type],Reference.prize_draw AS [Prize Draw],Reference.Call_back_date AS [Call back date],Reference.call_back AS [Call back],Reference.comments AS Comments,Reference.IsCompleted FROM Customer INNER JOIN参考ON客户。[customer_ID] =参考。[customer_ID] WHERE IIF(IsNull(Forms!Call_Back_Search1!Combo5),True,(Reference.agent_ID)= Forms!Call_Back_Search1!Combo5)和((Reference.Call_back_date)表单之间!Call_Back_Search1!StartDateTxt和Forms!Call_Back_Search1!EndDatetxt)And(([ Reference.IsCompleted])= 0);