Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2012

    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!

  2. #2
    Join Date
    May 2005
    Nevada, USA
    Provided Answers: 6
    I would use a variable for the SQL so you can see what it is resolving to:


    Are you sure those are all fields in the table?

  3. #3
    Join Date
    Feb 2012
    Actually, it was in a variable before, I took it out to see if I had a problem with my variable, also for ease of showing what I had going on here.

    Yes, all the fields are in the table. Hmmm, maybe a double check is in order, as its the first time this is being run on the 2012 table that was created by my collegue...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts