|
表中根本就没有数量字段,怎么输入数量??
请增加数量字段到表中
关系很乱,一输入数据就出错,
单位关系应该是文本型,
这些你自己修改。
代码还是给你,(大概是这个意思吧)
Private Sub 数量_AfterUpdate()
Dim intPiece As Integer
Dim strRlt As String
Dim strCriteria As String
If Not IsNull(Me.商品编号) Then
If IsNull(Me.箱数) Then
strCriteria = "商品编号=" & Me.商品编号
strRlt = DLookup("单位关系", "农工商商品资料", strCriteria)
intPiece = Val(Mid(strRlt, InStr(strRlt, "*") + 1))
Me.箱数 = Me.数量 / intPiece
End If
End If
End Sub
Private Sub 箱数_BeforeUpdate(Cancel As Integer)
Dim intPiece As Integer
Dim strRlt As String
Dim strCriteria As String
If Not IsNull(Me.商品编号) Then
If IsNull(Me.数量) Then
strCriteria = "商品编号=" & Me.商品编号
strRlt = DLookup("单位关系", "农工商商品资料", strCriteria)
intPiece = Val(Mid(strRlt, InStr(strRlt, "*") + 1))
Me.数量 = Me.箱数 * intPiece
End If
End If
End Sub |
|