Yes/No Queries

J

Jess

I have set up a query that states:

Field = TrustAccountsIncluded
Table = TBL_RelationshipManagers
Update To = DCount("UserID","TBL_RMClients","[RMLastName]
='" &[TBL_RelationshipManagers].[RMLastName] & "'")

But now, I want to add one more stipulation that says only
count the records where the field Duplicate in the table
CustomerAccounts is equal to No (I have it in the table as
a Yes/No field type), can someone help me with this?
 
B

Bas Cost Budde

Jess said:
I have set up a query that states:

Field = TrustAccountsIncluded
Table = TBL_RelationshipManagers
Update To = DCount("UserID","TBL_RMClients","[RMLastName]
='" &[TBL_RelationshipManagers].[RMLastName] & "'")

But now, I want to add one more stipulation that says only
count the records where the field Duplicate in the table
CustomerAccounts is equal to No (I have it in the table as
a Yes/No field type), can someone help me with this?

Update To = DCount("UserID","TBL_RMClients","[RMLastName]='"
&[TBL_RelationshipManagers].[RMLastName] & "' AND Duplicate=False")
 
J

John Vinson

I have set up a query that states:

Field = TrustAccountsIncluded
Table = TBL_RelationshipManagers
Update To = DCount("UserID","TBL_RMClients","[RMLastName]
='" &[TBL_RelationshipManagers].[RMLastName] & "'")

But now, I want to add one more stipulation that says only
count the records where the field Duplicate in the table
CustomerAccounts is equal to No (I have it in the table as
a Yes/No field type), can someone help me with this?

The DCount() function's third argument is a text string which would be
a valid WHERE clause in a query (without the word WHERE) - so you can
just build it up piecewise:

Update To = DCount("UserID","TBL_RMClients","[RMLastName]
='" &[TBL_RelationshipManagers].[RMLastName] & "' AND [Duplicate] =
False")

HOWEVER!!!!

Storing this kind of count in a table field is probably a VERY BAD
IDEA. If a new record gets added to TBL_RMClients, or a client is
deleted, then the value stored in this field WILL BE WRONG, with no
obvious way to detect that it's wrong. I'd suggest just using the
DCount function (as modified) as a calculated field in a Query rather
than storing it at all.
 

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