DCount Expression; Invalid Date ???

D

Dave Elliott

It says the expression I intered has an invalid date

=Dcount([EmployeeID], "Employees", [EmployeeId] > '2' And
[WorkDate]=#??/??/????#)
 
W

Wayne Morgan

Is this exactly what you entered? If so, then question marks aren't a date.
Also, is EmployeeId a text or numeric field? The syntax you are showing
indicates a text field.

For DCount to work properly, all three parameters need to be passed as
strings.

=DCount("[EmployeeID]", "Employees", "[EmployeeId] > '2' And [WorkDate] =
#??/??/????#")

This is assuming that you're just using the question marks as place holders
for your example. Remove the single quotes from around the 2 if EmployeeId
is a numeric field. Are you trying to concatenate any values into the
function?
 
D

Dave Elliott

EmployeeID is a number, primary key in the employees table



Wayne Morgan said:
Is this exactly what you entered? If so, then question marks aren't a
date. Also, is EmployeeId a text or numeric field? The syntax you are
showing indicates a text field.

For DCount to work properly, all three parameters need to be passed as
strings.

=DCount("[EmployeeID]", "Employees", "[EmployeeId] > '2' And [WorkDate] =
#??/??/????#")

This is assuming that you're just using the question marks as place
holders for your example. Remove the single quotes from around the 2 if
EmployeeId is a numeric field. Are you trying to concatenate any values
into the function?

--
Wayne Morgan
MS Access MVP


Dave Elliott said:
It says the expression I intered has an invalid date

=Dcount([EmployeeID], "Employees", [EmployeeId] > '2' And
[WorkDate]=#??/??/????#)
 
D

Dave Elliott

Also, Wayne, the data is form 2 tables.
EmployeeID is form the Employees Table
Work Date is from the Hours table
the form I want to do this calculations uses both tables in the query
Time_Hours is the name of the query


Wayne Morgan said:
Is this exactly what you entered? If so, then question marks aren't a
date. Also, is EmployeeId a text or numeric field? The syntax you are
showing indicates a text field.

For DCount to work properly, all three parameters need to be passed as
strings.

=DCount("[EmployeeID]", "Employees", "[EmployeeId] > '2' And [WorkDate] =
#??/??/????#")

This is assuming that you're just using the question marks as place
holders for your example. Remove the single quotes from around the 2 if
EmployeeId is a numeric field. Are you trying to concatenate any values
into the function?

--
Wayne Morgan
MS Access MVP


Dave Elliott said:
It says the expression I intered has an invalid date

=Dcount([EmployeeID], "Employees", [EmployeeId] > '2' And
[WorkDate]=#??/??/????#)
 
D

Douglas J. Steele

If WorkDate doesn't exist in the Employee table, then you can't use it in
the DCount statement. Use the name of the query that joins them together
instead.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Dave Elliott said:
Also, Wayne, the data is form 2 tables.
EmployeeID is form the Employees Table
Work Date is from the Hours table
the form I want to do this calculations uses both tables in the query
Time_Hours is the name of the query


Wayne Morgan said:
Is this exactly what you entered? If so, then question marks aren't a
date. Also, is EmployeeId a text or numeric field? The syntax you are
showing indicates a text field.

For DCount to work properly, all three parameters need to be passed as
strings.

=DCount("[EmployeeID]", "Employees", "[EmployeeId] > '2' And [WorkDate] =
#??/??/????#")

This is assuming that you're just using the question marks as place
holders for your example. Remove the single quotes from around the 2 if
EmployeeId is a numeric field. Are you trying to concatenate any values
into the function?

--
Wayne Morgan
MS Access MVP


Dave Elliott said:
It says the expression I intered has an invalid date

=Dcount([EmployeeID], "Employees", [EmployeeId] > '2' And
[WorkDate]=#??/??/????#)
 

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