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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I am getting a too few parameters, expected 1 error message HELP?

Status
Not open for further replies.

CDerosier

Programmer
Jan 5, 2003
10
0
0
US
I am currently writing a program in VBA and when I execute the following SQL code I get a too few parameters expected 1. What is wrong with this code and why am I getting the error message?

dim Dbs As database
Set Dbs = CurrentDb
Me.STATE.SetFocus
tempgroup = Me.STATE.Text
sSQL = "Select STATE, [AVG ANNUAL PRECIP (inches)] From Table1 Where [STATE]= '" & tempgroup & "' order by [avg annual precip (inches)] "
Set MyRS = Dbs.OpenRecordset(sSQL, dbOpenDynaset)

I have to use the brackets around AVG ANNUAL PRECIP (inches) because if I don't I get a type mismatch error.

Does anyone have any suggestions?


 
This is just a guess but I'm thinking that it is interpreting the [ ] as a parameter request - a la Access

What you need to remember is that SQL HATES spaces

If at all possible, change the field name to have _ instead of spaces - may well resolve the problem Rgds
Geoff
"Some cause happiness wherever they go; others whenever they go."
-Oscar Wilde
 
Are you absolutely sure you are spelling "AVG ANNUAL PRECIP (inches)" correctly? I just put together a test and it worked ok. But when I altered the name slightly, I got the error message you described.
 
I double checked the spelling and it is exactly the same as in the table. If I take out the (inches) it gives me a type mismatch error but no parameters error.
Could it be because I imported the table from excel?
 
i just took out the spaces and the (inches) from the table and the code worked Thanks for the help!
 
I'm glad you got it working.

Please take Geoff's advice to heart and avoid fancy column names when designing tables. Access allows you to get away with a lot of things most DBMS packages won't. If and when your app outgrows Access and you need to go to SQL Server, for example, it can save you a lot of grief.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top