簡體   English   中英

使用多個標准的 DCount

[英]DCount using Multiple Criteria

我不確定為什么我的代碼沒有返回正確數量的記錄。 我有:

counter = DCount("*", "tbl1", "[Check] = FALSE OR DateDiff('d', [CheckDate], 
Date()) > 365 And [Room] = '" & Forms!frmSelect.txbSelect.Value & "'")
checkIndicator.Caption = "(" & counter & ")" & " available!"

似乎[Check] = FALSE OR DateDiff('d', [CheckDate], Date()) > 365工作正常,但整個代碼不是。 提前致謝!

您當前的代碼將返回tbl1的記錄計數,其中:

  • [Check] = FALSE (對於[Room]任何值)

或者

  • DateDiff('d', [CheckDate], Date()) > 365 AND [Room] = Forms!frmSelect.txbSelect.Value

根據所需的結果,我猜您需要[Room] = Forms!frmSelect.txbSelect.Value始終為真,因此邏輯應按以下方式用括號括起來:

"([Check] = FALSE OR DateDiff('d', [CheckDate], Date()) > 365) And [Room] = '" & Forms!frmSelect.txbSelect.Value & "'"
 ^                                                           ^
 |                                                           |
 +----------------- Added parentheses here ------------------+

現在返回tbl1的記錄計數,其中:

  • [Room] = Forms!frmSelect.txbSelect.Value

  • [Check] = FALSE OR DateDiff('d', [CheckDate], Date()) > 365

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM