Problems with reports, functions, and queries with parameters

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • highbulp
    New Member
    • Oct 2006
    • 1

    Problems with reports, functions, and queries with parameters

    I'm trying to use the DCount() function in the Report Header of a new report. The ReportSource for this report is a parametered Query. My DCount call looks like:
    DCount("[fieldname]","[QueryName]","[fieldname]=1")
    where QueryName is the name of the parametered Query. However, when I go to Print Preview, instead of giving the count Access simply displays "#ERROR"

    I'm pretty sure that the problem comes from the fact that the query has parameters. When I tested the same syntax on a query without parameters, everything worked fine. I think Access is having issues resolving the fact that QueryName is, in fact, a query which returns a table. Usually Access has no problem with this query if I don't call it from the form, as it just prompts me to fill in the parameters. This is the case when I set QueryName as the ReportSource. However, Access does not prompt me when I reference QueryName in the DCount(), and so I wonder if I've really confused it.

    Any ideas on how I can fix this? Ideally, I'd like to be able to reference the table that is the ReportSource from inside the DCount(). But really I just want to be able to include a Count of the number of records which have a certain value in a certain field, where those records match the criteria established by a form/query set.

    Thanks for helping a newbie!
  • PEB
    Recognized Expert Top Contributor
    • Aug 2006
    • 1418

    #2
    I'm affraid but parametred queries with dlookup Dsum Dcount doesn't work...

    In fact what is the transmitted parameter ???....

    Sorry but look for other way

    If your report is based on the respective parametred query its better to use Sum() Count() and so on functions instaed the oders ones!

    Best regards!

    Comment

    Working...