好的,我在另一篇文章中问了这个问题,但它变得太乱了......
这是我想做的......
首先,有一个名为Age的表,用户输入年龄范围,表中可以输入多个年龄范围...表中的字段名称是“MinAge”和“MaxAge”。
我有一个切换按钮,用户可以验证数据以确保四件事:
Call Shell("c:/path/to/python.exe filename.py")
通过,因为最小年龄是>对于每行的最大年龄,第2行的最小年龄>第1行的最大年龄,第2行的最小年龄依次比第1行的最大年龄大1。
- Min Age Max Age
ROW 1: 0 5
ROW 2: 6 8
失败,因为第1行和第2行中有空值
Min Age Max Age
ROW 1: 5
ROW 2: 6
失败,因为最小年龄大于第1行的最大年龄
Min Age Max Age
ROW 1: 10 5
ROW 2: 6 8
失败,因为第2行的最小年龄小于第1行的最大年龄.....
答案 0 :(得分:1)
我会在一个数组中处理它。似乎很顺利过去
Dim i as long, j as long, z as long q as long
Dim arr As Variant
Dim arr2() As String, strMsg as string
Dmi rs as recordset
Dmim errBool as Boolean
set rs = CurrentDb.OpenRecordset("your query statement")
With rs
rs.MoveLast
q = rs.RecordCount
rs.MoveFirst
z = rs.Fields.Count
End With
ReDim xaRR(q, z)
arr = rs.GetRows(q)
For j = LBound(arr, 2) To UBound(arr, 2)
For i = LBound(arr, 1) To UBound(arr, 1)
arr2(j, i) = arr(i, j)
Next i
Next j
errBool = True
for i = lbound(arr2,1) to ubound(arr2,1)
if i > 0
If arr2(i,0)= arr2(i-1,1)+1 then
errBool = false
strMsg = "Start point isnt an increment by 1 of the last position"
end if
if (IsNull(arr2(i,0)) Or (IsNull(arr2(i,0))) = True Then
errBool = false
strMsg = "You have null values"
End if
If arr2(i,0) > arr2(i,1) then
errBool = False
strMsg = "You min is larger than your max for row " & i
End
end if
next i
if errBool = False then
MsgBox strMsg
End if
rs.Close
Set rs = Nothing