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!

too few parameters error. need help please

Status
Not open for further replies.

Stuartp

Technical User
Feb 22, 2001
178
GB
I am trying to write a query in VB6 to take from an Access table rows where month is greater than a certain figure and insert them into another table. I thought this would be more or less straightforward but I keep getting an error message i dont understand.

The query i have written is:

INSERT INTO [presreport] ([rep], [month], [existingAppts], [newBusAppts], [newBusConverted], [percentageConverted]) " & _
"SELECT [rep], [month], [existingAppts], [newBusAppts], [newBusConverted], [percentageConverted]" & _
"FROM [presentations]" & _
"WHERE [presentations].[month] >= [presMonth]"

This produces the error "too few parameters. expected 1"

I dont know what this means! I have identified that the problem lies with the variable name in the WHERE clause i.e. the presMonth. If I replace this with a figure it works fine. But this does not suit.... I need a variable, but I do not know what else I must do to make this work.

Some help to put me on the right path will be much appreciated!

Thanks.

Stuart

 
It has to do with how you are executing your query. Post your code, and we will find it.
 
I mean the code you are using to execute the query. Such as cnConnection.Execute SQL or rsRecordset.open,SQL,cnConnection
 
Thanks for your help guys.... your comments made me experiment a little more. I have got it working now. The problem lay in the use of squared brackets round the variable name.... so writing [" & presMonth & "] caused it to produce an error, but writing " & presMonth & " seems to be OK...

Stuart

 
The common cause for this error is the fact that the database engine cannot find a particular parameter or field it is looking for.
This is the case with your code. As mikhailwaxman correctly points out your have incorrect syntax in your sql (it should be like mikhailwaxman's example) meaning the db engine is looking for the presmonth as a query parameter and cannot find it.

Hope this helps clarify.

sdh
::)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top