Solved

too few parameters

Posted on 1998-04-14
5
307 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
  • 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 50 total points
ID: 1973816
Great
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

746 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now