|
本帖最后由 fnsmydyang 于 2009-2-8 19:41 编辑
请问各位网友这段代码错在哪里?为什么DMAX返回的值有问题(小数点正常,偶数正常,奇数错误)例如:17 返回值为165,应返回16才对.
Private Sub 当日序号_AfterUpdate()
Dim rs As DAO.Recordset
Dim rs1 As DAO.Recordset
Dim i As Integer
Dim j As Integer
Dim t As Variant
Dim a(2)
Set rs = CurrentDb.OpenRecordset("SELECT 材质,厚,宽,长 FROM 订单明细 WHERE 当日序号='" & Me![当日序号] & "'")
If rs.RecordCount <= 0 Then Exit Sub
Me![材质] = rs(0)
a(0) = rs(1)
a(1) = rs(2)
a(2) = rs(3)
For i = 0 To UBound(a) - 1
For j = n + 1 To UBound(a)
If a(i) > a(j) Then
t = a(i): a(i) = a(j): a(j) = t
End If
Next j
Next i
Me![规格] = a(0) & "*" & a(1) & "*" & a(2)
Dim temp As Variant
temp = Val(IIf(DLookup("加工方法", "材质", "材质='" & Me![材质] & "'") = "火割", 1, 2))
a(0) = Val(a(0))
Me![实际厚度] = DMax("厚度", "材料厚度表", "类型='" & temp & "' and 厚度<='" & a(0) & "'")
End Sub |
|