dcount with more than one criteria

  • Thread starter Thread starter Vjeran
  • Start date Start date
V

Vjeran

UPDATE RADNI_STAZ INNER JOIN DJECA ON RADNI_STAZ.jmbg=DJECA.jmbg SET
RADNI_STAZ.go_br_djeca_h = DCount("*","djeca","jmbg=" & Chr(13) &
radni_staz.jmbg & Chr(13));

how to add 2 more criterias in statement above(in dcount function criteria)
i need to add this:
djeca.god<18
djeca.hendikep="DA"


--
 
i have tried like this, but it counts all, not just under 18:

UPDATE RADNI_STAZ INNER JOIN DJECA ON RADNI_STAZ.jmbg=DJECA.jmbg SET
RADNI_STAZ.go_br_djeca_h = DCount("*","djeca","jmbg=" & Chr(13) &
radni_staz.jmbg & Chr(13)) WHERE djeca.god<18 AND djeca.hendikep='DA';
 
Try

UPDATE RADNI_STAZ INNER JOIN DJECA
ON RADNI_STAZ.jmbg=DJECA.jmbg
SET RADNI_STAZ.go_br_djeca_h = DCount("*","djeca","jmbg='" & radni_staz.jmbg
& "' AND god<18 AND hendikep='DA'")

When you are building the third parameter for the DCount function, you
should be building the equivalent of a where clause without the word
"where". I don't understand the Chr(13) you had in your posted query. In
my Access version (USA), Chr(13) is a carriage return; Chr(34) is a quote
mark ("); and Chr(39) is an apostrophe (').

You may need to include yourWhere clause in your query if you are only
interested in updating Radni_Staz.jmbg if there is an associated record in
DJECA with the values of God<18 and hendikep = 'DA'

UPDATE RADNI_STAZ INNER JOIN DJECA
ON RADNI_STAZ.jmbg=DJECA.jmbg
SET RADNI_STAZ.go_br_djeca_h = DCount("*","djeca","jmbg='" & radni_staz.jmbg
& "' AND god<18 AND hendikep='DA'")WHERE djeca.god<18 AND
djeca.hendikep='DA'


Vjeran said:
i have tried like this, but it counts all, not just under 18:

UPDATE RADNI_STAZ INNER JOIN DJECA ON RADNI_STAZ.jmbg=DJECA.jmbg SET
RADNI_STAZ.go_br_djeca_h = DCount("*","djeca","jmbg=" & Chr(13) &
radni_staz.jmbg & Chr(13)) WHERE djeca.god<18 AND djeca.hendikep='DA';
 
thank you John
you saved me a lot of time this week...

....chr(13) was copy/paste mistake...

John Spencer said:
Try

UPDATE RADNI_STAZ INNER JOIN DJECA
ON RADNI_STAZ.jmbg=DJECA.jmbg
SET RADNI_STAZ.go_br_djeca_h = DCount("*","djeca","jmbg='" & radni_staz.jmbg
& "' AND god<18 AND hendikep='DA'")

When you are building the third parameter for the DCount function, you
should be building the equivalent of a where clause without the word
"where". I don't understand the Chr(13) you had in your posted query. In
my Access version (USA), Chr(13) is a carriage return; Chr(34) is a quote
mark ("); and Chr(39) is an apostrophe (').

You may need to include yourWhere clause in your query if you are only
interested in updating Radni_Staz.jmbg if there is an associated record in
DJECA with the values of God<18 and hendikep = 'DA'

UPDATE RADNI_STAZ INNER JOIN DJECA
ON RADNI_STAZ.jmbg=DJECA.jmbg
SET RADNI_STAZ.go_br_djeca_h = DCount("*","djeca","jmbg='" & radni_staz.jmbg
& "' AND god<18 AND hendikep='DA'")WHERE djeca.god<18 AND
djeca.hendikep='DA'
 
Back
Top