SQL error

B

Bill

With strSession, strYear, intMtgNo, strTopic and strChariman
having been set in code, the following SQL statement is created.
I don't see what's causing the 3061 run-time error.


strSQL = "INSERT INTO TopicHist(Session, Year, MtgNo, Topic,
Chairman)"
strSQL = strSQL & " Values(" & strSession & ", " & strYear & ",
" & intMtgNo & ", "
strSQL = strSQL & """" & strTopic & """, " & """" & strChairman
& """);"

Debug.Print strSQL

CurrentDb.Execute strSQL

Run-time Error: '3061';
Too few parameters. Expected 1.

There are 5 variables and 5 values! What's missing?


Immediate Window:
INSERT INTO TopicHist(Session, Year, MtgNo, Topic, Chairman)
Values(April, 1975, 1, "Direction And Responsibilities", "Jack Lane");
 
D

Dirk Goldgar

Bill said:
With strSession, strYear, intMtgNo, strTopic and strChariman
having been set in code, the following SQL statement is created.
I don't see what's causing the 3061 run-time error.


strSQL = "INSERT INTO TopicHist(Session, Year, MtgNo,
Topic, Chairman)"
strSQL = strSQL & " Values(" & strSession & ", " &
strYear & ", " & intMtgNo & ", "
strSQL = strSQL & """" & strTopic & """, " & """" &
strChairman & """);"

Debug.Print strSQL

CurrentDb.Execute strSQL

Run-time Error: '3061';
Too few parameters. Expected 1.

There are 5 variables and 5 values! What's missing?


Immediate Window:
INSERT INTO TopicHist(Session, Year, MtgNo, Topic, Chairman)
Values(April, 1975, 1, "Direction And Responsibilities", "Jack Lane");

April is a string value, so it should be enclosed in quote like
"Direction And Responsibilities" and "Jack Lane".
 

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

Similar Threads


Top