Too few parameters. Expected 1 (1 Viewer)

AccOUCH

Registered User.
Local time
Today, 15:50
Joined
Sep 27, 2018
Messages
25
I'm trying to find out why this is wrong, while in the queries generator it works properly.
Code:
SELECT Count(Audi.Id) AS CuentaDeId FROM Audi WHERE (((Len." & filtro & ") Between #" & Format(Me!fechamin, "mm/dd/yyyy") & "# And #" & Format(Me!fechamax, "mm/dd/yyyy") & "#))

With some dates slightly different It works, but I think that when It does not find any value in this Table, the error appears. No idea if it's a problem of the Query design, or if there is another way to define it, or not. Any clue, anyone?

Thanks in advance!
 

theDBguy

I’m here to help
Staff member
Local time
Today, 15:50
Joined
Oct 29, 2018
Messages
21,358
Hi. What is in filtro? Is Len a name of a table? If you Debug.Print your SQL statement, what does it look like?
 

AccOUCH

Registered User.
Local time
Today, 15:50
Joined
Sep 27, 2018
Messages
25
Hi. What is in filtro? Is Len a name of a table? If you Debug.Print your SQL statement, what does it look like?

filtro equals to a certain date, for instance: 02/01/19.
Len is the name of a Table.
If I debug print this SQL statement...nothing is depicted.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 15:50
Joined
Oct 29, 2018
Messages
21,358
Can you post the SQL statement for the query that works? It doesn't make sense to have a field called 02/01/19, so you can have something like Len.02/01/19. I don't think that will work.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 17:50
Joined
Feb 28, 2001
Messages
27,001
Beware of using certain things as table, field, query, report, macro, module, or entry point names. LEN() is a "Length" function that tells you the size (in bytes) of some data element. Using a table named LEN is going to screw up a lot of things.

You are trying to count something that has a date in it. But something is wrong with the WHERE ... BETWEEN clause. You SHOULD avoid using special characters like "/" in any name anywhere anytime. And if filtro is a date, you would have an illegal field name as well after you did the "Len." substitution.
 

plog

Banishment Pending
Local time
Today, 17:50
Joined
May 11, 2011
Messages
11,612
filtro equals to a certain date, for instance: 02/01/19.
Len is the name of a Table.

That means you have named fields in Len after dates? That's an issue larger than whatever is not working in this query. You've designed your table(s) incorrectly.

Then just to inform, if you truly do have a field named like 1/1/2019 you would have to escape it in code with brackets: Len.[1/1/2019]
Field names that start with non-letters (or have non-alphanumeric characaters in them) require that.

Also, your query has no frame of reference for Len. Tables that you want to reference in a query should appear in the FROM or JOIN clauses. You only have 1 table there.
 

AccOUCH

Registered User.
Local time
Today, 15:50
Joined
Sep 27, 2018
Messages
25
Hi guys, thanks for your answers. But the project has been shut down, so...Till next time. Even thou, your last points have been very helpful!
 

Users who are viewing this thread

Top Bottom