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

PatAccess

Registered User.
Local time
Today, 15:06
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)
 
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.
 
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
 
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?
 
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.
 
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

Back
Top Bottom