sql server 2008 - Insert record into SQL table based on values from another table -
i have sql database access front end. trying employeeid 1 table, , insert it, along other values table. can't figure out doing wrong. not getting errors, , when @ values, there. insert command not working. know getting employeeid other table working. ideas? in advance help!
private sub command666_click() dim db dao.database dim rs dao.recordset dim strsql, strsql2, strsql3 string dim st date dim st2 date dim vempid, vworkcode integer dim vhours, vhours2 double dim vdtadd date strsql = "select * tblemployees" set db = currentdb() set rs = db.openrecordset(strsql, dbopendynaset, dbseechanges) rs.movefirst 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 , rs!startdate < st2 strsql2 = "insert tbltimeavailable (employeeid, noofhours, dateadded, workcode) values (@vempid, @vhours, @vdtadd, @vworkcode)" db.execute strsql2 else if rs!startdate >= st2 strsql3 = "insert 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
Comments
Post a Comment