|
附件是先判断是否已经存在的库位,如果存在就在架位数量上进行累加,否则就添加一条新数据,下面的代码报错,请看看,谢谢
Private Sub YourSaveButton_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Set db = CurrentDb
Set rs = db.OpenRecordset("tblLocation", dbOpenDynaset)
If Not (IsNull(Me.焊材材质编号) Or IsNull(Me.接收架位) Or IsNull(Me.接收数量)) Then
strSQL = "SELECT * FROM tblLocation WHERE [焊材材质编号] = '" & Me.焊材材质编号 & "' AND [架位] = '" & Me.接收架位 & "'"
rs.FindFirst strSQL
If rs.NoMatch Then
rs.AddNew
rs![焊材材质编号] = Me.焊材材质编号
rs![架位] = Me.接收架位
rs![架位数量] = Me.接收数量
rs.Update
Else
If rs![架位] = Me.接收架位 Then
rs.Edit
rs![架位数量] = rs![架位数量] + Me.接收数量
rs.Update
Else
rs.AddNew
rs![焊材材质编号] = Me.焊材材质编号
rs![架位] = Me.接收架位
rs![架位数量] = Me.接收数量
rs.Update
End If
End If
End If
rs.Close
Set rs = Nothing
Set db = Nothing
End Sub |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|