470,810 Members | 915 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,810 developers. It's quick & easy.

DCount problem

Hi,

I have a problem with DCount, the following code doesn't work:

DCount("[OrderDetailID]", "qryOrder", "([OrderID] = Me![OrderID] AND [CatID]
= 'drink')" > 0

Please help.

Thank you.

Paul
Nov 13 '05 #1
2 1801
The WHERE part of the DCount is a string, and as you have it the string is

"DCount("[OrderDetailID]", "qryOrder", "([OrderID] = Me![OrderID] AND
[CatID]
= 'drink')" > 0
"

If the OrderID in question is, say, 42, what you really want is

DCount("[OrderDetailID]", "qryOrder", "([OrderID] = 42 AND [CatID]
= 'drink')" > 0

To get this, you need to put the reference to the control outside the
string, so that the value in the control gets used instead of the reference
to it:

DCount("[OrderDetailID]", "qryOrder", "([OrderID] = " & Me![OrderID] & " AND
[CatID]
= 'drink')" > 0

"Paul T. RONG" <et***@hotmail.com> wrote in message
news:nt******************@news.chello.at...
Hi,

I have a problem with DCount, the following code doesn't work:

DCount("[OrderDetailID]", "qryOrder", "([OrderID] = Me![OrderID] AND [CatID] = 'drink')" > 0

Please help.

Thank you.

Paul

Nov 13 '05 #2
Dave,

Thank you very much. It works very well.

Paul

"Dave M" <dm******@island.net> 写入消息新闻
:NT1rd.388827$nl.180856@pd7tw3no...
The WHERE part of the DCount is a string, and as you have it the string is

"DCount("[OrderDetailID]", "qryOrder", "([OrderID] = Me![OrderID] AND
[CatID]
= 'drink')" > 0
"

If the OrderID in question is, say, 42, what you really want is

DCount("[OrderDetailID]", "qryOrder", "([OrderID] = 42 AND [CatID]
= 'drink')" > 0

To get this, you need to put the reference to the control outside the
string, so that the value in the control gets used instead of the reference to it:

DCount("[OrderDetailID]", "qryOrder", "([OrderID] = " & Me![OrderID] & " AND [CatID]
= 'drink')" > 0

"Paul T. RONG" <et***@hotmail.com> wrote in message
news:nt******************@news.chello.at...
Hi,

I have a problem with DCount, the following code doesn't work:

DCount("[OrderDetailID]", "qryOrder", "([OrderID] = Me![OrderID] AND

[CatID]
= 'drink')" > 0

Please help.

Thank you.

Paul


Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Classified | last post: by
1 post views Thread by Megan | last post: by
4 posts views Thread by Will | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.