我看到了这个链接about the value returned by DMAX in Access 2010 但是,当我在我的vba代码中测试它以找到最大值时,似乎总是跳过将nullNum设置为0.感谢任何帮助。
DoCmd.SetWarnings False
If DMax("[Eff Date]", "400_CF_BREAK_LOG") <> "" Or Not IsNull(DMax("[Eff Date]", "400_CF_BREAK_LOG")) Or DMax("[Eff Date]", "400_CF_BREAK_LOG") <> 0 Then
oldDate = DMax("[Eff Date]", "400_CF_BREAK_LOG")
Else:
nullNum = 0
End If
If DMin("[Eff Date]", "203_Differences") > oldDate Or nullNum = 0 Then
Run Query;
End If
DoCmd.SetWarnings True
我的问题是A)nullNum总是被设置为0.或者2)我的Dmin逻辑是不正确的(但我要解释一下;如果新日期的最小值是,我只运行查询大于最古老的日期)。我不认为我的逻辑是错误的。
答案 0 :(得分:0)
Variant数据类型可以存储Null值。尝试获取DMax值并只检查Null值。
DoCmd.SetWarnings False
Dim maxDate As Variant
maxDate = DMax("[Eff Date]", "400_CF_BREAK_LOG")
If Not IsNull(maxDate) Then
If DMin("[Eff Date]", "203_Differences") > maxDate Then
'Run Query
End If
End If
DoCmd.SetWarnings True