Private Sub Command4_Click()
DoCmd.Close
Dim db As DAO.Database
Dim rs As DAO.Recordset, rst As DAO.Recordset
Dim str As String, n As Integer
Set db = CurrentDb
db.Execute ("delete * from 薪资表")
Set rst = db.OpenRecordset("人事基本资料")
rst.MoveFirst
While Not rst.EOF
Set rs = db.OpenRecordset("薪资表")
rs.AddNew
rs(0) = rst(0)
rs(1) = rst(17)
rs(4) = rst(12)
rs(5) = rst(13)
rs(6) = rst(14)
rs(8) = rst(15)
rs(13) = rst(16)
If rst(10) = True Then
rs(14) = 75
Else
rs(14) = 0
End If
If rst(11) = True Then
rs(11) = 30
End If
n = ((Year(Date) - Left(rst(0), 4)) * 12 + Month(Date) - 1 - Mid(rst(0), 5, 2)) / 12 - 0.5
Select Case n
Case 0, 1, 2
rs(10) = n * 15
Case 3, 4, 5
rs(10) = n * 20
Case Is > 5
rs(10) = 100 + 30 * (n - 5)
End Select
rs.Update
rst.MoveNext
Wend
rs.Close
rst.Close
db.Close
DoCmd.OpenQuery ("薪资查询")
End Sub