View Full Version : dcount to reference a different table?


oasis.alex
05-10-2005, 10:04 AM
I'm trying to get a query to count all the pole positions, fastest laps, first places etc a driver has had, here is a picture of the sample for fastest lap, i have a small problem i cant get it to only count the current drivers fastest laps

so i need to know how i get the drivers.id to match with the driver id in the results table


http://www.alexsawczuk.co.uk/access.jpg

basically i want to know how i get the dcount to reference a different table?

Jon K
05-10-2005, 05:50 PM
In the query, Group By the drivers' [ID] field, too. Then reference [Drivers].[ID] in the DCount() expression like this (The +0 changes the DCount results to numeric values.):-

Expr1: DCount("*","IndividualResults","[Fastest Lap]=Yes and [Driver]='" & [Drivers].[ID] & "'")+0

If the drivers' ID is a numeric field, remove the single-quotes surrounding its values:-
Expr1: DCount("*","IndividualResults","[Fastest Lap]=Yes and [Driver]=" & [Drivers].[ID])+0
__________________________________________________ ______________

Since [Fastest Lap] is a YesNo field, in fact you can use a much simpler Expression:-

Exprl: -Sum([IndividualResults].[Fastest Lap])

which runs much faster than DCount.
.