我有一个带有Access前端的SQL数据库。我试图从一个表中获取employeeid,并将其与其他值一起插入到另一个表中。我无法弄清楚我做错了什么。我没有得到任何错误,当我看到价值观时,他们就在那里。我的插入命令不起作用。我也知道从另一个表中获取employeeid是有效的。有任何想法吗?在此先感谢您的帮助!
Private Sub Command666_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSql, strsql2, strsql3 As String
Dim st As Date
Dim st2 As Date
Dim vempid, vworkcode As Integer
Dim vhours, vhours2 As Double
Dim vdtadd As Date
strSql = "SELECT * FROM tblEmployees"
Set db = CurrentDb()
Set rs = db.OpenRecordset(strSql, dbOpenDynaset, dbSeeChanges)
rs.MoveFirst
Do While Not rs.EOF
vempid = rs!EmployeeID
vhours = 40
vhours2 = 8
vdtadd = Date
vworkcode = 1
st = DateAdd("m", 6, Date)
st2 = DateAdd("m", 7, Date)
If rs!StartDate >= st And rs!StartDate < st2 Then
strsql2 = "Insert into tblTimeAvailable (EmployeeID, NoofHours, DateAdded, WorkCode) values (@vempid, @vhours, @vdtadd, @vWorkCode)"
db.Execute strsql2
Else
If rs!StartDate >= st2 Then
strsql3 = "Insert into tblTimeAvailable (EmployeeID, NoofHours, DateAdded, WorkCode) values (@vempid, @vhours2, @vdtadd, @vWorkCode)"
db.Execute strsql3
End If
End If
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
MsgBox ("Sick Time added")
End Sub