Private Sub Command16_Click()
Dim kc As Integer
Me.编号 = Me.编号1
Me.品名 = Me.品名1
Me.领用理由 = Me.领用理由1
Me.领用数量 = Me.领用数量1
If IsNull(Me.领用数量1) Then
MsgBox "请填写领用数量!", vbCritical, "提示:"
Me.领用数量1.SetFocus
Exit Sub
End If
If IsNull(Me.领用理由1) Then
MsgBox "请填写领用理由!", vbCritical, "提示:"
Me.领用理由1.SetFocus
Exit Sub
End If
kc = Me.现库存量 - 领用数量1
Me.剩余数量 = kc
DoCmd.SetWarnings False
ssql = "update 领用明细 set 剩余数量= '" & Me.剩余数量 & "' where 品名='" & Me.品名1 & "'"
DoCmd.RunSQL ssql
MsgBox "数据已经更新!"
DoCmd.Close
End Sub
Private Sub Form_Load()
DoCmd.GoToRecord , , acNewRec
End Sub
Private Sub Form_Open(Cancel As Integer)
End Sub
Private Sub 编号1_AfterUpdate()
Me.品名1 = DLookup("品名", "产品明细", "编号='" & Me.编号1 & " ' ")
Me.现库存量 = DLookup("剩余数量", "领用明细", "编号='" & Me.编号1 & " ' ")
End Sub
Private Sub 主体_Click()
End Sub
把以上代码复制到窗体里就可以了。窗体里原有代码远不删除!