Thanks a bunch.
Just as background, we want to be able to show summary data of complaints
that were overturned, upheld, and unresolved for certain groups.
The problem is, for each group that shows, the category is repeated.
The users don't care about the underlying groups in this particular report--
they only care about the each category and how many unresolved, upheld and
overturned there are.
In order to accomplish this, Group # or Group Name must be filtered but not
selected.
I am presently using a listbox to facilitate the user being able to select a
particular group they want to filter for. I've written code that
effectively creates a strFilter variable (and it would work if I passed it to
the docmd.Open report command) but now since they don't want the group # or
name to show, I can't have a query that filters but doesn't select unless I
fill it with something --hence the form textbox field.
The report that I open is called rptYTDDOIDOL_TPA
Yes, it would be great if I could change the underlying query of the report
before it opens on varying conditions.
Here is the entire query:
SELECT YTDDOIDOL01DGroupDecision.[Type of category],
Sum(YTDDOIDOL01DGroupDecision.Overturned) AS SumOfOverturned,
Sum(YTDDOIDOL01DGroupDecision.Upheld) AS SumOfUpheld,
Sum(YTDDOIDOL01DGroupDecision.Unresolved) AS SumOfUnresolved
FROM YTDDOIDOL01DGroupDecision
GROUP BY YTDDOIDOL01DGroupDecision.[Type of category],
YTDDOIDOL01DGroupDecision.[Group #]
HAVING (((YTDDOIDOL01DGroupDecision.[Group
#])=[Forms]![frmSelectReports]![frmSub]![lstBoxChoice]));
Marshall Barton said:
jonefer said:
I have code that produces the correct comparison operator with the string of
the textbox:
so my SQL statement in the query looks like this:
HAVING (((GroupDecision.[Group
#])=[Forms]![frmSelectReports]![frmSub]![lstBoxChoice]));
so lets say the string in the textbox were ([Group #] like '*')
... it should work right? and give me every group.
that same textbox could also give me ([Group #] IN('2223', '2224'))
All these strings work if I paste them directly into the query in place of
the parameter. Why don't they work if they're in a textbox as a parameter?
That can not possibly work. A parameter must represent a
value in an expression, not the entire expression or even
part of an expression that includes an operator.
Also, you didn't post the rest of you query's SQL, but I'll
bet you should be using WHERE instead of HAVING. Where is
used to select the data for the query to process, Having is
used to filter out entire groups after the GROUP BY clause
has been completed.
Back to your problem. To filter on expressions, as you cite
above, you have to construct the entire SQL statement in
code. While you're doing that, it's easy to use the
parameter's value instead of asking the query to find it for
you. I'd be happy to take a shot at the code if you'll post
your query's entire SQL statement along with an explanation
of where/how it's being used.