Solved Run-time error '3061'. Too few parameters. Expected 1 (1 Viewer)

PatAccess

Registered User.
Local time
Today, 05:13
Joined
May 24, 2017
Messages
284
Hello Guys,
Why am I getting error 3061 with this code? I checked all fields name to ensure they match my query and they do. What is the problem?
Code:
    Dim strSQL As String
    
    strSQL = "SELECT [SupplyCateg], [Brand],[ItemNo],[Color], [Size], [LastOrdered] FROM QryEmailReminderList WHERE [LastOrdered] BETWEEN DATEADD(DAY,-30,DATE()) AND DATE() "
    
    Set rs = CurrentDb.OpenRecordset(strSQL, dbOpenDynaset, dbSeeChanges)
 

plog

Banishment Pending
Local time
Today, 04:13
Joined
May 11, 2011
Messages
11,646

Isaac

Lifelong Learner
Local time
Today, 02:13
Joined
Mar 14, 2017
Messages
8,777
usually that means there is a typo in your query sql..like a field that doesn't exist, you've misspelled, etc
at least in my experience it often means that and has nothing to do with parameters.
 

Isaac

Lifelong Learner
Local time
Today, 02:13
Joined
Mar 14, 2017
Messages
8,777
Yes, after considering, I believe plog & gasman are correct - in your particular case, it's about the date function.

(Although that error can crop up in much more vague and parameter-less situations, i.e. this code will cause the exact same error FWIW)

Code:
Sub Foo()
Dim db As DAO.Database, td As DAO.TableDef, rs As DAO.Recordset

Set db = CurrentDb
Set td = db.CreateTableDef("tblTest")
td.Fields.Append td.CreateField("column1", dbText)
db.TableDefs.Append td

Set rs = db.OpenRecordset("select NonExistentColumn from tblTest")

End Sub
 

PatAccess

Registered User.
Local time
Today, 05:13
Joined
May 24, 2017
Messages
284
Thank you Guys, all of your inputs help. I was off base of most. Here is the working statement
Code:
strSQL = "SELECT [SupplyCateg], [Brand],[ItemNo],[Color], [Size], [LastOrdered] FROM QryEmailReminderList WHERE [LastOrdered] >= DATE() - 30 "

BUT I have a question. What SQL language does Access uses exactly? I was told T-SQL. Is that correct?
 

Minty

AWF VIP
Local time
Today, 10:13
Joined
Jul 26, 2013
Messages
10,371
It's a flavour of SQL similar but not the same as T-SQL.

Most of the common functions are "standard" but once you get into string manipulations, wildcards, and date functions there are differences.
 

Isaac

Lifelong Learner
Local time
Today, 02:13
Joined
Mar 14, 2017
Messages
8,777
You could say Access SQL is "special". But not "special" in a real positive way, like t-sql is ;)
 

Users who are viewing this thread

Top Bottom