Type Mismatch Error In SQL String

G

Guest

I've been converting my RunSQL methods to db.Execute to trap errors. I'm
generating a Type Mismatch error on the 2nd strSQL assignment statement
below. Can anyone identify where I'm erring?

Thank you.
Sprinks

Dim db As DAO.Database
Dim strSQL As String
Set db = DBEngine(0)(0)

strSQL = "INSERT INTO TSHistory ( StaffID, PeriodEnding )"
strSQL = strSQL & " SELECT StaffWithMonthRecs.StaffID,
Timesheet.PeriodStartDate + 13 AS PeriodEnding" & _
strSQL = strSQL & " FROM StaffWithMonthRecs, Timesheet" & _
strSQL = strSQL & " INNER JOIN Timesheet ON StaffWithMonthRecs.StaffID =
Timesheet.StaffID"

db.Execute strSQL, dbFailOnError
Set db = Nothing
 
D

Duane Hookom

Try this without the TimeSheet table in there twice and removing strSQL =
strSQL where you are using line continuations:

strSQL = "INSERT INTO TSHistory ( StaffID, PeriodEnding )"
strSQL = strSQL & " SELECT StaffWithMonthRecs.StaffID, " & _
" Timesheet.PeriodStartDate + 13 " & _
" FROM StaffWithMonthRecs " & _
" INNER JOIN Timesheet ON StaffWithMonthRecs.StaffID =
Timesheet.StaffID"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top