Criteria

L

Lori

I am trying to create a calculated control on a form. I need to restrict the
count using two criterion. I can only get it to work with one criterion - I
have a correct count if I just use the status criterion below. I need to
also include the peer group restriction. Any ideas on how my syntax is
wrong? Thanks!

This code works (only one criterion):

=DCount("[Vendor_Nbr]","qry_Zip_Code_Vendors","[Status_Code] = 'Active'")

This code won't work (it's what I need to use with 2 criterion):

=DCount("[Vendor_Nbr]","qry_Zip_Code_Vendors","[Status_Code] = 'Active'" And
"[Peer_Group_Code] = '11'")
 
K

Klatuu

The And needs to be inside the quotes. Also, the way you have it coded, you
are expecting [Peer_Group_Code] to be a text fields.
=DCount("[Vendor_Nbr]","qry_Zip_Code_Vendors","[Status_Code] = 'Active' And
[Peer_Group_Code] = '11'")

If [Peer_Group_Code] is a numeric field:
=DCount("[Vendor_Nbr]","qry_Zip_Code_Vendors","[Status_Code] = 'Active' And
[Peer_Group_Code] = 11")
 
L

Lori

Peer_Group_Code is a numeric field - I copied the code in that you shared
below where peer group is numeric and got an error - the control displays
#Name? instead of a number. I verified the field names are correct. What
else is wrong with the syntax, are the quotes misplaced?

Klatuu said:
The And needs to be inside the quotes. Also, the way you have it coded, you
are expecting [Peer_Group_Code] to be a text fields.
=DCount("[Vendor_Nbr]","qry_Zip_Code_Vendors","[Status_Code] = 'Active' And
[Peer_Group_Code] = '11'")

If [Peer_Group_Code] is a numeric field:
=DCount("[Vendor_Nbr]","qry_Zip_Code_Vendors","[Status_Code] = 'Active' And
[Peer_Group_Code] = 11")


Lori said:
I am trying to create a calculated control on a form. I need to restrict the
count using two criterion. I can only get it to work with one criterion - I
have a correct count if I just use the status criterion below. I need to
also include the peer group restriction. Any ideas on how my syntax is
wrong? Thanks!

This code works (only one criterion):

=DCount("[Vendor_Nbr]","qry_Zip_Code_Vendors","[Status_Code] = 'Active'")

This code won't work (it's what I need to use with 2 criterion):

=DCount("[Vendor_Nbr]","qry_Zip_Code_Vendors","[Status_Code] = 'Active'" And
"[Peer_Group_Code] = '11'")
 
L

Lori

Please disregard my previous email - I was missing a bracket - thanks for
your help!



Klatuu said:
The And needs to be inside the quotes. Also, the way you have it coded, you
are expecting [Peer_Group_Code] to be a text fields.
=DCount("[Vendor_Nbr]","qry_Zip_Code_Vendors","[Status_Code] = 'Active' And
[Peer_Group_Code] = '11'")

If [Peer_Group_Code] is a numeric field:
=DCount("[Vendor_Nbr]","qry_Zip_Code_Vendors","[Status_Code] = 'Active' And
[Peer_Group_Code] = 11")


Lori said:
I am trying to create a calculated control on a form. I need to restrict the
count using two criterion. I can only get it to work with one criterion - I
have a correct count if I just use the status criterion below. I need to
also include the peer group restriction. Any ideas on how my syntax is
wrong? Thanks!

This code works (only one criterion):

=DCount("[Vendor_Nbr]","qry_Zip_Code_Vendors","[Status_Code] = 'Active'")

This code won't work (it's what I need to use with 2 criterion):

=DCount("[Vendor_Nbr]","qry_Zip_Code_Vendors","[Status_Code] = 'Active'" And
"[Peer_Group_Code] = '11'")
 
K

Klatuu

Looks correct to me. The error indicates it can't find a field named
Peer_Group_Code. Have you checked your query to be sure it is correct there?


Lori said:
Peer_Group_Code is a numeric field - I copied the code in that you shared
below where peer group is numeric and got an error - the control displays
#Name? instead of a number. I verified the field names are correct. What
else is wrong with the syntax, are the quotes misplaced?

Klatuu said:
The And needs to be inside the quotes. Also, the way you have it coded, you
are expecting [Peer_Group_Code] to be a text fields.
=DCount("[Vendor_Nbr]","qry_Zip_Code_Vendors","[Status_Code] = 'Active' And
[Peer_Group_Code] = '11'")

If [Peer_Group_Code] is a numeric field:
=DCount("[Vendor_Nbr]","qry_Zip_Code_Vendors","[Status_Code] = 'Active' And
[Peer_Group_Code] = 11")


Lori said:
I am trying to create a calculated control on a form. I need to restrict the
count using two criterion. I can only get it to work with one criterion - I
have a correct count if I just use the status criterion below. I need to
also include the peer group restriction. Any ideas on how my syntax is
wrong? Thanks!

This code works (only one criterion):

=DCount("[Vendor_Nbr]","qry_Zip_Code_Vendors","[Status_Code] = 'Active'")

This code won't work (it's what I need to use with 2 criterion):

=DCount("[Vendor_Nbr]","qry_Zip_Code_Vendors","[Status_Code] = 'Active'" And
"[Peer_Group_Code] = '11'")
 

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

Similar Threads

On Current event 3
Record Count 1
On Current event 5
Help! - calculated control 6
Count question 0
Count code 3
run time error 2001 2
table design - calculated field 1

Top