DCount Expression; Invalid Date ???

  • Thread starter Thread starter Dave Elliott
  • Start date Start date
D

Dave Elliott

It says the expression I intered has an invalid date

=Dcount([EmployeeID], "Employees", [EmployeeId] > '2' And
[WorkDate]=#??/??/????#)
 
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?
 
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]=#??/??/????#)
 
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]=#??/??/????#)
 
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]=#??/??/????#)
 
Back
Top