Link to home
Start Free TrialLog in
Avatar of ntollfree
ntollfree

asked on

too few parameters

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
Avatar of devtha
devtha
Flag of United States of America image

In a sql string you need to declare the parameters before you actually execute it.
Devtha
Avatar of ntollfree
ntollfree

ASKER

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
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]
Yup, you've assumed correctly and that works, cheers
ASKER CERTIFIED SOLUTION
Avatar of Bangerter
Bangerter

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial