Solved

too few parameters

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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
type of query 11 42
Access 2016 5 54
Can not open the Access Help ? 3 53
Restoring a form to its default settings 3 27
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

772 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