i have a table named employees
and it contains the following data:
employee_name - department - titles - job
i want to count how many Engineer in the department named project control
i used this but it not worked
=DCount("[titels]"; "[Employees]"; "[title] = 'Engineer '"&
[department]=project control)
it gives me error
so what is the problem
There is a difference between using the Ampersand (&) and the word And
in the where clause.
What is the actual value stored as [Title]? is it "Engineer " (note
the trailing space) or "Engineer" ? Each is a different value from the
other, so you must not add a space if it is not part of the actual
value. You used ='Engineer '. Most likely it should be ='Engineer'.
Also, what datatype is [department]? Is it a number datatype? Or Text?
What is project control? Is that the name of a control on the form
which displays the department number? If so, because the control name
contains a space you must enclose it in brackets.
Assuming [department] is a number datatype, then try this:
=DCount("[titels]"; "[Employees]"; "[title] = 'Engineer' AND
[department]=" & [project control])
However, if department is in fact a Text datatype, then try:
=DCount("[titels]"; "[Employees]"; "[title] = 'Engineer' AND
[department]= '" & [project control] & "'")
Note the unusual spelling of the field named "titels" above. If that
is the correct spelling of the field name, that is fine. However if it
is a misspelling of a field named "Titles" you need to fix it in your
code.