Solved

too few parameters

Posted on 1998-04-14
5
311 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SPROC to look for existing record in passed table name 7 46
Excel if Match convert to Access 16 63
Password on a button in Access 2013 7 33
Syntax Error in Query 7 30
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…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of utilizing SQL Server functions 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 Ac…
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.

930 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