Data type mismatch in criteria expression

C

ccholai

SELECT TOP 1 TreeCount.CDate, TreeCount.Trial, Count(TreeCount.Leafs)
AS NoOfLeafs, Avg(TreeCount.TreeC) AS TreeCount
FROM TreeCount
GROUP BY TreeCount.CDate, TreeCount.Trial
HAVING FrondCount.Trial = " &trial &"

Without the having statement - it works fine but once I put in the
criteria it comes up with Data type mismatch in criteria expression

Any help would be very appreciated. Thanks
 
A

Allen Browne

Sorry: I don't understand that HAVING clause either.

What's FrondCount? Where does this table come in? Its not in the FROM
clause.

What's &trial? Where did this come from? What are the quotes for? They are
not else around the string.
 
C

ccholai

Hi Allen,

sorry - the HAVING clause should read:

HAVING TreeCount.Trial = " &trial &"

"&trial&" is a parameter value - the user types in the trial and and
should pick up the associated info for that trial.
 
J

John Vinson

Allen,

sorry - the HAVING clause should read:

HAVING TreeCount.Trial = " &trial &"

"&trial&" is a parameter value - the user types in the trial and and
should pick up the associated info for that trial.

Access does not use & as a delimiter for parameters; it uses square
brackets.

John W. Vinson[MVP]
 
A

Allen Browne

Ah, yes.
John is correct.

Try:
SELECT TOP 1 TreeCount.CDate,
TreeCount.Trial,
Count(TreeCount.Leafs) AS NoOfLeafs,
Avg(TreeCount.TreeC) AS TreeCount
FROM TreeCount
GROUP BY TreeCount.CDate, TreeCount.Trial
HAVING TreeCount.Trial = [How Many];

If Trial is a numeric field (not a text field), can I also suggest that you
declare this parameter. Choose Parameters on the Query menu. Enter exactly
the same name, and specify the data type (e.g. Long for a whole number.)
 
C

c8tz

Thanks guys - it's ok now!!! :)
Allen said:
Ah, yes.
John is correct.

Try:
SELECT TOP 1 TreeCount.CDate,
TreeCount.Trial,
Count(TreeCount.Leafs) AS NoOfLeafs,
Avg(TreeCount.TreeC) AS TreeCount
FROM TreeCount
GROUP BY TreeCount.CDate, TreeCount.Trial
HAVING TreeCount.Trial = [How Many];

If Trial is a numeric field (not a text field), can I also suggest that you
declare this parameter. Choose Parameters on the Query menu. Enter exactly
the same name, and specify the data type (e.g. Long for a whole number.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

John Vinson said:
Access does not use & as a delimiter for parameters; it uses square
brackets.

John W. Vinson[MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top