DCount Syntax

  • Thread starter Thread starter DS
  • Start date Start date
D

DS

I have DCount expression in a unbound field on a continous form. I'm
trying to have it count how many other [LineID] matches the [LineID] of
the current Record.

=DCount("LineID","SalesDetails","[LineID]=[LineID]")

Thanks
DS
 
DS said:
I have DCount expression in a unbound field on a continous form. I'm
trying to have it count how many other [LineID] matches the [LineID]
of the current Record.

=DCount("LineID","SalesDetails","[LineID]=[LineID]")

You'll get closer with this:

=DCount("LineID","SalesDetails","[LineID]=" & [LineID])

but on a continuous form it will still only show you -- for all rows --
the value that is calculated for the current record. So it will show
you the same value for all rows, but change that as you navigate from
one row to another.

You could base the form on a query that woul calculate that for each
record, though. Something like:

SELECT
SalesDetails.*,
(
SELECT Count(*) FROM SalesDetails T
WHERE T.LineID = SalesDetails.LineID
) AS LineCount
FROM
SalesDetails;
 
I have DCount expression in a unbound field on a continous form. I'm
trying to have it count how many other [LineID] matches the [LineID] of
the current Record.

=DCount("LineID","SalesDetails","[LineID]=[LineID]")

This will count the records in the SalesDetails table for which the
LineID in that record is equal to itself - all of them, in other
words.

Pull the current record's LineID out of the quotes:

=DCount("*", "[SalesDetails]", "[LineID] = " & [LineID])

Thus if the current record has LineID equal to 1245, the criteria
argument to DCount will be

[LineID] = 1245

and you'll get the count you want.

I use * rather than LineID since you're counting matching records, not
lineID's - the results will be the same, though.

John W. Vinson[MVP]
 
John said:
I have DCount expression in a unbound field on a continous form. I'm
trying to have it count how many other [LineID] matches the [LineID] of
the current Record.

=DCount("LineID","SalesDetails","[LineID]=[LineID]")


This will count the records in the SalesDetails table for which the
LineID in that record is equal to itself - all of them, in other
words.

Pull the current record's LineID out of the quotes:

=DCount("*", "[SalesDetails]", "[LineID] = " & [LineID])

Thus if the current record has LineID equal to 1245, the criteria
argument to DCount will be

[LineID] = 1245

and you'll get the count you want.

I use * rather than LineID since you're counting matching records, not
lineID's - the results will be the same, though.

John W. Vinson[MVP]
Thanks, John....It worked great!!!
DS
 

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

DMax Problem 3
Table Relationship for database 3
SQL Syntax Problem 2
Fixing up field with a row number to become PK 1
IF Statement 5
Query data 1
No Records Then 4
SumProduct too slow 6

Back
Top