以下代码似乎不起作用(在MS Access中的查询条件中添加)。当我只使用dtDateFrom尝试条件时,它可以正常工作,但是当我应用第二个条件时,它永远不会起作用。
= [Forms]![frm_generate_reports]![dtDateFrom]和< = [Forms]![frm_generate_reports]![dtDateTo]
答案 0 :(得分:0)
下面的代码比较了两个日期
'Check if dates are valid
If Me.dtDateTo <= Me.dtDateFrom Then
'Pop up message asking the user to change the dates as they are not valid
MsgBox ("Sorry, the 'To' Date cannot occur before the 'From' date" & vbCrLf & "Please choose a different date range")
Else
'Do Something else
End If
你的代码因为AND而无效 - 它通常用于测试两个条件为真。
实施例
a = 5
如果&lt; 10和a> 4 做点什么
这两个条件都必须成立才能正常工作