Dcount in Query

R

Robert_DubYa

I am having trouble creating an expression in the following query:

SELECT [tblCitemRunQty-Step5-CItemsOnly].Child,
[tblCitemRunQty-Step5-CItemsOnly].Month,
[tblCitemRunQty-Step5-CItemsOnly].Branch,
DCount("Month","tblCitemRunQty-Step5-CItemsOnly","[Branch] = " & [Branch]) AS
Expr1
FROM [tblCitemRunQty-Step5-CItemsOnly];

the problem is in my Dcount statement:

DCount("Month","tblCitemRunQty-Step5-CItemsOnly","[Branch] = " &
'[Branch]').

I do not use this function much so I must refresh my self each time and this
time I am failing.

I am trying to make this statement dynamic in the query. If I use a static
value I get the result I would expect

example:

DCount("Month","tblCitemRunQty-Step5-CItemsOnly","[Branch] = 'myvalue'"

any clue on what I am doing wrong?

thanks as always.
 
W

Wayne Morgan

DCount("Month","tblCitemRunQty-Step5-CItemsOnly","[Branch] = " &
'[Branch]')

Are you trying to concatenate in the current value of Branch? If so, try:

DCount("Month","tblCitemRunQty-Step5-CItemsOnly","[Branch] = '" & [Branch] &
"'")

--
Wayne Morgan
MS Access MVP


Robert_DubYa said:
I am having trouble creating an expression in the following query:

SELECT [tblCitemRunQty-Step5-CItemsOnly].Child,
[tblCitemRunQty-Step5-CItemsOnly].Month,
[tblCitemRunQty-Step5-CItemsOnly].Branch,
DCount("Month","tblCitemRunQty-Step5-CItemsOnly","[Branch] = " & [Branch])
AS
Expr1
FROM [tblCitemRunQty-Step5-CItemsOnly];

the problem is in my Dcount statement:

DCount("Month","tblCitemRunQty-Step5-CItemsOnly","[Branch] = " &
'[Branch]').

I do not use this function much so I must refresh my self each time and
this
time I am failing.

I am trying to make this statement dynamic in the query. If I use a
static
value I get the result I would expect

example:

DCount("Month","tblCitemRunQty-Step5-CItemsOnly","[Branch] = 'myvalue'"

any clue on what I am doing wrong?

thanks as always.
 
R

Robert_DubYa

Wayne,

Thanks for your reponse. I am trying to count the number of instances a
value appears in the month column where the value in the "Branch" = the value
in the query.

thanks,
Robert

Wayne Morgan said:
DCount("Month","tblCitemRunQty-Step5-CItemsOnly","[Branch] = " &
'[Branch]')

Are you trying to concatenate in the current value of Branch? If so, try:

DCount("Month","tblCitemRunQty-Step5-CItemsOnly","[Branch] = '" & [Branch] &
"'")

--
Wayne Morgan
MS Access MVP


Robert_DubYa said:
I am having trouble creating an expression in the following query:

SELECT [tblCitemRunQty-Step5-CItemsOnly].Child,
[tblCitemRunQty-Step5-CItemsOnly].Month,
[tblCitemRunQty-Step5-CItemsOnly].Branch,
DCount("Month","tblCitemRunQty-Step5-CItemsOnly","[Branch] = " & [Branch])
AS
Expr1
FROM [tblCitemRunQty-Step5-CItemsOnly];

the problem is in my Dcount statement:

DCount("Month","tblCitemRunQty-Step5-CItemsOnly","[Branch] = " &
'[Branch]').

I do not use this function much so I must refresh my self each time and
this
time I am failing.

I am trying to make this statement dynamic in the query. If I use a
static
value I get the result I would expect

example:

DCount("Month","tblCitemRunQty-Step5-CItemsOnly","[Branch] = 'myvalue'"

any clue on what I am doing wrong?

thanks as always.
 
W

Wayne Morgan

In that case, you'll have to concatenate in the value as previously
recommended. Also, the syntax you were using would be for Branch as a text
value. If it is a number data type, the syntax will change to:

DCount("Month","tblCitemRunQty-Step5-CItemsOnly","[Branch] = " & [Branch])


--
Wayne Morgan
MS Access MVP


Robert_DubYa said:
Wayne,

Thanks for your reponse. I am trying to count the number of instances a
value appears in the month column where the value in the "Branch" = the
value
in the query.

thanks,
Robert

Wayne Morgan said:
DCount("Month","tblCitemRunQty-Step5-CItemsOnly","[Branch] = " &
'[Branch]')

Are you trying to concatenate in the current value of Branch? If so, try:

DCount("Month","tblCitemRunQty-Step5-CItemsOnly","[Branch] = '" &
[Branch] &
"'")

--
Wayne Morgan
MS Access MVP


Robert_DubYa said:
I am having trouble creating an expression in the following query:

SELECT [tblCitemRunQty-Step5-CItemsOnly].Child,
[tblCitemRunQty-Step5-CItemsOnly].Month,
[tblCitemRunQty-Step5-CItemsOnly].Branch,
DCount("Month","tblCitemRunQty-Step5-CItemsOnly","[Branch] = " &
[Branch])
AS
Expr1
FROM [tblCitemRunQty-Step5-CItemsOnly];

the problem is in my Dcount statement:

DCount("Month","tblCitemRunQty-Step5-CItemsOnly","[Branch] = " &
'[Branch]').

I do not use this function much so I must refresh my self each time and
this
time I am failing.

I am trying to make this statement dynamic in the query. If I use a
static
value I get the result I would expect

example:

DCount("Month","tblCitemRunQty-Step5-CItemsOnly","[Branch] = 'myvalue'"

any clue on what I am doing wrong?

thanks as always.
 

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