|
怎样实现输入已有的条码数据实现更新数量和金额 而不追加新行?在此无限感谢了
Dim XSNum As Single
Dim i As Integer
Dim STemp As String
Dim Rs As ADODB.Recordset
Dim Cunzai As Boolean
Set Rs = New ADODB.Recordset
STemp = "Select * From 销售"
Rs.Open STemp, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
XSNum = InputBox("请输入您购买该商品的数量:", "购买数量", 1)
Cunzai = False
If Rs.RecordCount < 1 Then
Cunzai = False
Else
For i = 1 To Rs.RecordCount
If Rs("销售单编号") = VarArray(0) And Rs("条码号") = Me.输入 Then
Rs("销售数量") = Rs("销售数量") + XSNum
Rs("销售金额") = Rs("销售数量") * Rs("销售单价")
Rs.Update
Me.销售_子窗体.Requery
Cunzai = True
Rs.Update
Exit For
Else
Rs.MoveNext
End If
Next i
End If
If Cunzai = False Then
Rs.AddNew
Rs("销售单编号") = Me.销售单编号
Rs("条码号") = Me.[库存明细 子窗体]![条码号]
Rs("商品编号") = Me.[库存明细 子窗体]![商品编号]
Rs("产品名称") = Me.[库存明细 子窗体]![产品名称]
Rs("型号规格") = Me.[库存明细 子窗体]![型号规格]
Rs("销售数量") = XSNum
Rs("销售单价") = Me.[库存明细 子窗体]![单价]
Rs("销售金额") = Rs("销售数量") * Me.[库存明细 子窗体]![单价]
Rs("结算日期") = Now
Rs("经手人") = "9999"
Rs.Update
Me.销售_子窗体.Requery
End If
'
Set Rs = Nothing
Exit__输入DblClick:
Set Rs = Nothing
Exit Sub
|
|