tgifgemini 12 Junior Poster

Hello members,
I am trying to execute the module below (SQL statement) and I am getting the above error: "Syntax error in FROM clause" on this line

Call db.Execute(strSQL)

.
When I hovered the mouse over the SQL string variable, it shows this line of code:

strSQL = "Insert Into TblProgrammersHours (ProjectID,ProgrammerInitials, CurrProgHrs, PrevProgHrs, TotalProgHrs, Positions) Select * From ("

and I can't figure out what the problem is.

Any ideas, please?

Thanks.
tgif.

Re: VB6 - Create mew table using input from two other tables
Dim Db As Database
Dim DbPath As String
Dim DbName As String
Dim strSQL As String
Dim rsOutfile As Recordset

DbPath = "\\515opsisdallf00008\SHARED\PyrlApps\PTStest2\"


'DbPath = "C:\"

DbName = "PTS.mdb"

Set Db = OpenDatabase(DbPath & DbName)

strSQL = "Insert Into TblProgrammersHours (ProjectID,ProgrammerInitials, CurrProgHrs, PrevProgHrs, TotalProgHrs, Positions) Select * From ("

strSQL = strSQL & "Select TblRequests.ProjectID, TblPersonnel.Initials, TblRequests.Prog1hrs, TblRequests.PrevProg1Hrs, TblRequests.TotalProg1hrs, 1 As Position " _
& "From TblRequests Inner Join tblPersonnel On TblPersonnel.[Name] = TblRequests.Personnel1 "

strSQL = strSQL & "Union All " _
& "  Select TblRequests.ProjectID, TblPersonnel.Initials, TblRequests.Prog2hrs, TblRequests.PrevProg2Hrs, TblRequests.TotalProg2hrs, 2 " _
& "From TblRequests Inner Join tblPersonnel On TblPersonnel.[Name] = TblRequests.Personnel2"

strSQL = strSQL & "Union All " _
& "  Select TblRequests.ProjectID, TblPersonnel.Initials, TblRequests.Prog3hrs, TblRequests.PrevProg3Hrs, TblRequests.TotalProg3hrs, 3 " _
& "From TblRequests Inner Join tblPersonnel On TblPersonnel.[Name] = TblRequests.Personnel3"

strSQL = strSQL & "Union All " _
& "  Select TblRequests.ProjectID, TblPersonnel.Initials, TblRequests.Prog4hrs, TblRequests.PrevProg4Hrs, TblRequests.TotalProg4hrs, 4 " _
& "From TblRequests Inner Join tblPersonnel On TblPersonnel.[Name] = TblRequests.Personnel4"

strSQL = strSQL & "Union All " _
& "  Select TblRequests.ProjectID, TblPersonnel.Initials, TblRequests.Prog5hrs, TblRequests.PrevProg5Hrs, TblRequests.TotalProg5hrs, 5 " _
& "From TblRequests Inner Join tblPersonnel On TblPersonnel.[Name] = TblRequests.Personnel5"

strSQL = strSQL & "Union All " _
& "  Select TblRequests.ProjectID, TblPersonnel.Initials, TblRequests.Prog6hrs, TblRequests.PrevProg6Hrs, TblRequests.TotalProg6hrs, 6 " _
& "From TblRequests Inner Join tblPersonnel On TblPersonnel.[Name] = TblRequests.Personnel6"

Call db.Execute(strSQL) [B]<=== error on this line[/B]