Reputation: 93
I am trying to run a small append query in VBA to add new data for a duplicated record.
strsql = " INSERT INTO tblQuoteNumGeneration ( JobID, BaseQuote, Yearnum, RevisionNum )"
strsql = strsql & " SELECT JobID = [Forms]![JobQuote]![JobID], BaseQuote = " & _
QuoteNumber & ", YearNum = " & MyYear & ", RevisionNum = " & NewRev & ""
strsql = strsql & " FROM tblQuoteNumGeneration"
However, I am getting an Expected parameters
error. On a debug.print
, it outputs:
INSERT INTO tblQuoteNumGeneration ( JobID, BaseQuote, Yearnum, RevisionNum )
SELECT JobID = [Forms]![JobQuote]![JobID], BaseQuote = 14937, YearNum = 20, RevisionNum = 2
FROM tblQuoteNumGeneration
Could someone who is a bit more versed in SQL help point me to my mistake?
Upvotes: 0
Views: 45
Reputation: 199
You have incorrect SQL statement generated. Instead of:
INSERT INTO tblQuoteNumGeneration ( JobID, BaseQuote, Yearnum, RevisionNum )
SELECT JobID = [Forms]![JobQuote]![JobID], BaseQuote = 14937, YearNum = 20, RevisionNum = 2
FROM tblQuoteNumGeneration
you should have:
INSERT INTO tblQuoteNumGeneration ( JobID, BaseQuote, Yearnum, RevisionNum )
SELECT JobID, BaseQuote, Yearnum, RevisionNum
FROM tblQuoteNumGeneration
Upvotes: 1