代码如下:
Private Sub 支付修改_Click()
Dim strSQL As String
Dim strType As String '支付方式
Dim startDate As Date '开始日期
Dim endDate As Date '结束日期
Dim strName As String '姓名
If IsNull(Me.同行姓名) Then
MsgBox "同行姓名不能为空值!", vbCritical, "提示"
Me.同行姓名.SetFocus
Exit Sub
End If
If IsNull(Me.录入日期) Then
MsgBox "开始日期不能为空值!", vbCritical, "提示"
Me.录入日期.SetFocus
Exit Sub
End If
If IsNull(Me.截止日期) Then
MsgBox "截止日期不能为空值!", vbCritical, "提示"
Me.截止日期.SetFocus
Exit Sub
End If
If IsNull(Me.支付方式) Then
MsgBox "支付方式不能为空值!", vbCritical, "提示"
Me.支付方式.SetFocus
Exit Sub
End If
startDate = Me.录入日期
endDate = Me.截止日期
strType = Me.支付方式
If strType = "未付款" Then
MsgBox "您指定的支付方式不正确!", vbCritical, "提示"
Me.支付方式.SetFocus
Exit Sub
End If
If MsgBox("您确认要支付修改吗?", _
vbExclamation + vbYesNo + vbDefaultButton2, "提示") = vbNo Then
Exit Sub
End If
strName = Me.同行姓名
Me.销售出库子窗体.SourceObject = ""
strSQL = "UPDATE 销售出库 SET 销售出库.支付方式 = '" & strType & "'" _
& " WHERE 录入日期 Between #" & startDate & "# And #" & endDate & "# AND 同行姓名='" & strName & "' AND 支付方式='未付款'"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
Me.销售出库子窗体.SourceObject = "销售出库2"
End Sub