我有三个DM用于查找三列中的最小数字。唯一的问题是当我有一个空列时,它返回空白。我怎样才能考虑空列?
这是我正在使用的代码。
Private Sub UpdatePriority_Click()
Dim MinGOPri As Variant
Dim MinSRPri As Variant
Dim MinSOPri As Variant
MinGOPri = DMin("[GOPri]", "[Projects]", "Projects.ProjNo = Activity.ProjNo")
MinSRPri = DMin("[StrPri]", "[Projects]", "Projects.ProjNo = Activity.ProjNo")
MinSOPri = DMin("[SOPri]", "[Projects]", "Projects.ProjNo = Activity.ProjNo")
Overal_Priority.Requery
Overal_Priority = IIf(((IIf([MinGOPri] < [MinSRPri], [MinGOPri], [MinSRPri])))
< [MinSOPri], ((IIf([MinGOPri] < [MinSRPri], [MinGOPri], [MinSRPri]))), [MinSOPri])
End Sub
答案 0 :(得分:2)
如果您希望找到三者中的最小值,则可以在DMin为空时插入“大于其他所有值”的值:
' Very large value.
Const Superior As Long = 9999
Dim MinGOPri As Variant
Dim MinSRPri As Variant
Dim MinSOPri As Variant
MinGOPri = Nz(DMin("[GOPri]", "[Projects]", "Projects.ProjNo = Activity.ProjNo"), Superior)
MinSRPri = Nz(DMin("[StrPri]", "[Projects]", "Projects.ProjNo = Activity.ProjNo"), Superior)
MinSOPri = Nz(DMin("[SOPri]", "[Projects]", "Projects.ProjNo = Activity.ProjNo"), Superior)