|
Private Sub cmdCalculate_Click()
Dim strSQL1, strsql2 As String
If IsNull(Me.cboTableName) Then Exit Sub
strSQL1 = " UPDATE " & Me.cboTableName & " SET " & _
" 划分 = Switch([积压时间] Like '*1-10*','D1-D2',[积压时间] Like '*11-20*','D2-D3',[积压时间] Like '*21-30*','D3-D4')," & _
" 奖金 = Switch([积压时间] Like '*1-10*',[单价]*0.2,[积压时间] Like '*11-20*',[单价]*0.3,[积压时间] Like '*21-30*',[单价]*0.4) where " & "Left([代码], 1) =1"
strsql2 = " UPDATE " & Me.cboTableName & " SET " & _
" 划分 = Switch([积压时间] Like '*1-10*','D1-D2',[积压时间] Like '*11-20*','D2-D3',[积压时间] Like '*21-30*','D3-D4')," & _
" 奖金 = Switch([积压时间] Like '*1-10*',[单价]*0.2,[积压时间] Like '*11-20*',[单价]*0.3,[积压时间] Like '*21-30*',[单价]*0.4) where " & "Left([代码], 1) =2"
Debug.Print strSQL1
Debug.Print strsql2
CurrentDb.Execute strSQL1
CurrentDb.Execute strsql2
Me.fsubQuery.Requery
Me.txtSumOfPrice1 = DSum("[单价]", Me.cboTableName, "[积压时间] Like '*1-10*'")
Me.txtSumOfPrice2 = DSum("[单价]", Me.cboTableName, "[积压时间] Like '*11-20*'")
Me.txtSumOfPrice3 = DSum("[单价]", Me.cboTableName, "[积压时间] Like '*21-30*'")
Me.txtSumOfBonus1 = DSum("[奖金]", Me.cboTableName, "[积压时间] Like '*1-10*'")
Me.txtSumOfBonus2 = DSum("[奖金]", Me.cboTableName, "[积压时间] Like '*11-20*'")
Me.txtSumOfBonus3 = DSum("[奖金]", Me.cboTableName, "[积压时间] Like '*21-30*'")
End Sub |
|