Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

too few parameters

Posted on 1998-04-14
5
Medium Priority
?
333 Views
Last Modified: 2012-05-04
Good Afternoon all,

I'm generating a big ole SQL statement in VBScript, it's giving me the
error

Microsoft OLE DB Provider for ODBC Drivers error '80040e10'
[Microsoft][ODBC Microsoft Access 97 Driver] Too few parameters.
Expected 1.
/avaccess/ListItemsBody.asp, line 205

So before I run the statement I print it, cut and paste it to the access
db and run it as a query, it runs beautifully.

Here is the statement

SELECT IIf(Closed=-1, Branch + " (c)", Branch) AS Location,
Str(SaleDate) AS SaleDat, LotCode, Registration, RegistrationDate, Make
+ ' ' + Model + ' ' + CC + ' ' + Derivative + ', ' + Body + ', ' +
Colour + ', ' + Doors + ' doors, ' + Gearbox + ', ' + Fuel + ', ' +
Str(Mileage) + ' miles ' + Warranty + ' ' + VAT AS description, 'New:' +
STR(New)+ '
Ret:' + STR(Retail)+ '
Cln:' + STR(Clean)+ '
Avg:' + STR(Average)+ '
Blw:' + STR(Below) AS CapPricing, 'Avg:' + STR(AveragePrice)+ '
Hi:' + STR(HighPrice)+ '
Lo:' + STR(LowPrice) AS Prices, Str(AverageMileage)+ '
' + Str(HighMileage)+ '
' + Str(LowMileage) AS Miles, Str(AverageSampleSize)+ '
' + Str(HighSampleSize)+ '
' + Str(LowSampleSize) AS sampleSizes FROM tblAVsnapshot ORDER BY Make


Now then you see right at the beginning of the statement the IIf
statement, if I replace that with the fieldname branch, it runs
beautifully. Anyone know why it's playing me up ?

tommy
0
Comment
Question by:ntollfree
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 6

Expert Comment

by:devtha
ID: 1973812
In a sql string you need to declare the parameters before you actually execute it.
Devtha
0
 

Author Comment

by:ntollfree
ID: 1973813
Don't understand what you mean. I have solved it by taking out '-1', so it's simply IIf(closed,yadda yadda yadda). How does this fit in with your answer. Sorry if Im being simple but I need to learn these things

tommy
0
 
LVL 2

Expert Comment

by:Bangerter
ID: 1973814
in your iif(closed = -1,Branch + " (c)",Branch) what exactly are you trying to do? is Branch a field name or is it just text? is closed a field name? if it is you need to have brackets around it. what is " (c)"? is it a text string?

i.e. iif([closed]=-1,[Branch] & " (c)",[Branch])

in my example statement i have assumed that [closed] is a field and that [Branch] is a field of type text and that the string    " (c)" is to be added to the string contained in the field [Branch]
0
 

Author Comment

by:ntollfree
ID: 1973815
Yup, you've assumed correctly and that works, cheers
0
 
LVL 2

Accepted Solution

by:
Bangerter earned 200 total points
ID: 1973816
Great
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question