Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Runtime error 3061 Too few parameters expected 1 with strSQL statement 2

Status
Not open for further replies.

vba317

Programmer
Mar 5, 2009
708
US
I am getting the runtime error 3061 on an strSQL statement. I have been working on this all day and I have come up blank on why I am getting this error. I am hoping to get some help.
The debug statement results are:
INSERT INTO CONS_Rejections (uci,RptPd,SvcPd,AID,EncID,TranID,RevCode,ReviewDt,ReviewComment) SELECT SPN AS u,dbo_bi_Rejections.revpd,dbo_bi_Rejections.svcpd,dbo_bi_Rejections.aid,dbo_bi_Rejections.eid,dbo_bi_Rejections.slid,dbo_bi_Rejections.revcode,dbo_bi_Rejections.revdate,dbo_bi_Rejections.revcomment FROM dbo_bi_Rejections WHERE dbo_bi_Rejections.revpd>373 AND dbo_bi_Rejections.clntid=97;

Tom

Code:
strSQL = "INSERT INTO CONS_Rejections (uci,RptPd,SvcPd,AID,EncID,TranID,RevCode,ReviewDt,ReviewComment) " & _
         "SELECT " & strUCI & " AS u" & ",dbo_bi_Rejections.revpd,dbo_bi_Rejections.svcpd,dbo_bi_Rejections.aid,dbo_bi_Rejections.eid," & _
                 "dbo_bi_Rejections.slid,dbo_bi_Rejections.revcode,dbo_bi_Rejections.revdate,dbo_bi_Rejections.revcomment " & _
                 "FROM dbo_bi_Rejections " & _
                 "WHERE dbo_bi_Rejections.revpd>" & iFyStart & " AND dbo_bi_Rejections.clntid=" & iClid & ";"
                 Debug.Print strSQL
                 CurrentDB.Execute strSQL
 
Is [uci] a text field? If so you would need to concatenate quotes into the statement. You can also get rid of the " As "

Code:
strSQL = "INSERT INTO CONS_Rejections (uci,RptPd,SvcPd,AID,EncID,TranID,RevCode,ReviewDt,ReviewComment) " & _
         "SELECT [COLOR=#EF2929]""[/color]" & strUCI & "[COLOR=#EF2929]""[/color] " & ",dbo_bi_Rejections.revpd, ...

Duane
Hook'D on Access
MS Access MVP
 
Now I get a syntax error

Code:
"SELECT """ & strUCI & """ & """ AS u """ & ",dbo_bi_Rejections.revpd,
 
Code:
"SELECT '" & strUCI & "' AS u,dbo_bi_Rejections.revpd,dbo_bi_Rejections.svcpd,dbo_bi_Rejections.aid,dbo_bi_Rejections.eid," & _

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Now I am getting Error 3346 number of query values and destination fields are not the same.

debugSQL results

INSERT INTO CONS_Rejections (uci,RptPd,SvcPd,AID,EncID,TranID,RevCode,ReviewDt,ReviewComment) SELECT 'SPN' AS u,dbo_bi_Rejections.r,dbo_bi_Rejections.revpd,dbo_bi_Rejections.svcpd,dbo_bi_Rejections.aid,dbo_bi_Rejections.eid,dbo_bi_Rejections.slid,dbo_bi_Rejections.revcode,dbo_bi_Rejections.revdate,dbo_bi_Rejections.revcomment FROM dbo_bi_Rejections rWHERE dbo_bi_Rejections.revpd>373 AND dbo_bi_Rejections.clntid=97;
 
Your insert has 9 fields and the select has 10. Your debug.print also contains " rWHERE "

I would also get rid of the " AS u " and all of the "dbo_bi_Rejections." since when you have only one table in the SELECT FROM the table name is not required.

Duane
Hook'D on Access
MS Access MVP
 
It was a spelling error. I just got it to work. Thanks for all your help!

Code:
strSQL = "INSERT INTO CONS_Rejections (uci,RptPd,SvcPd,AID,EncID,TranID,RevCode,ReviewDt,ReviewComment) " & _
                 "SELECT '" & strUCI & "'" & "AS u,dbo_bi_Rejections.revpd,dbo_bi_Rejections.svcpd,dbo_bi_Rejections.aid,dbo_bi_Rejections.eid," & _
                 "dbo_bi_Rejections.slid,dbo_bi_Rejections.revcode,dbo_bi_Rejections.revdate,dbo_bi_Rejections.revcomment " & _
                 "FROM dbo_bi_Rejections " & _
                 "WHERE dbo_bi_Rejections.revpd>" & iFyStart & " AND dbo_bi_Rejections.clntid=" & iClid & ";"
 
Glad to hear you got this working. My code would be a little more compact:

Code:
strSQL = "INSERT INTO CONS_Rejections " & _
     "(uci, RptPd, SvcPd, AID, EncID, TranID, RevCode, ReviewDt, ReviewComment) " & _
     "SELECT '" & strUCI & "' ,revpd, svcpd, aid, eid, slid, revcode, revdate, revcomment " & _
     "FROM dbo_bi_Rejections " & _
     "WHERE revpd > " & iFyStart & " AND clntid = " & iClid & ";"


Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top