Unanswered: MedianDB.OpenRecordset Too few parameters
I have a function that calculate the median that worked before, but today when changing a reference to a file name that changed with the new year, it no longer works.
I'm working in Access 2003.
The gist of what I'm running is:
Set MedianDB = CurrentDb()
Set ssMedian = MedianDB.OpenRecordset("SELECT " & FieldName & " FROM " & TableName & " WHERE " & Condition & " AND " & FieldName & " IS NOT NULL ORDER BY " & FieldName, dbOpenDynaset)
Set ssMedian = Nothing
Set MedianDB = Nothing
I'm passing FieldName, TableName and Condition to the function.
For example FieldName = "[Sale Price]"
TableName = "YTDSALES2012"
Condition = " [LUC at Sale] = 20 AND [TaxDist] LIKE '1*' AND [Sales Date]>=#1/1/ 2012# And [Sales Date]<#2/1/ 2012# AND [New] = '1New'"
The error I get is "Too few parameters. Expected 3."
Is there a problem with the brackets, and quotes and can you point out where and why?
Thanks for your help!