captainlove
captainlove
- Local time
- Today, 14:32
- Joined
- Apr 18, 2008
- Messages
- 39
I get an error after the group by statement in my VBA code saying expected: line number or label or statement or end of statement
My VBA is greyed out, after the group by clause. I suspect the error is before that. I have spent six hours on this. Can anyone out there help
Sql = "INSERT INTO tblTempHist (qcpID, revision_date,revision,Accepted, UserID,revID ) SELECT tblHistory.qcpID, " & _
"tblHistory.revision_date, tblHistory.revision, IIf(IsNull([UserID]),False,True) AS Accepted,qryHistLinkUser.userid, tblHistory.revid " & _
"FROM (tblQcp INNER JOIN tblHistory ON tblQcp.qcpID = tblHistory.qcpID) LEFT JOIN " & _
"qryHistLinkUser ON tblHistory.revid = qryHistLinkUser.REVID WHERE tblQcp.qcpID = " & Me.txtQcp & "AND qryHistLinkUser.UserId = " & Me.txtUser
"GROUP BY tblHistory.qcpID, " &_
"tblHistory.revision,qryHistLinkUser.userid, tblHistory.revision_date, IIf(IsNull([UserID]),False,True), tblHistory.revid "
DoCmd.RunSQL Sql

My VBA is greyed out, after the group by clause. I suspect the error is before that. I have spent six hours on this. Can anyone out there help
Sql = "INSERT INTO tblTempHist (qcpID, revision_date,revision,Accepted, UserID,revID ) SELECT tblHistory.qcpID, " & _
"tblHistory.revision_date, tblHistory.revision, IIf(IsNull([UserID]),False,True) AS Accepted,qryHistLinkUser.userid, tblHistory.revid " & _
"FROM (tblQcp INNER JOIN tblHistory ON tblQcp.qcpID = tblHistory.qcpID) LEFT JOIN " & _
"qryHistLinkUser ON tblHistory.revid = qryHistLinkUser.REVID WHERE tblQcp.qcpID = " & Me.txtQcp & "AND qryHistLinkUser.UserId = " & Me.txtUser
"GROUP BY tblHistory.qcpID, " &_
"tblHistory.revision,qryHistLinkUser.userid, tblHistory.revision_date, IIf(IsNull([UserID]),False,True), tblHistory.revid "
DoCmd.RunSQL Sql
