Datediff / Dcount datatype problem

  • Thread starter Thread starter Lee Hunter
  • Start date Start date
L

Lee Hunter

Using these two expressions, I'm getting a data type
error on the comparison in the Dcount function. Can
anyone provide the solution? Thank you!

Departure: DateDiff("n",FormatDateTime([Trips]![Departure
Time],4),FormatDateTime([Runs]![Dep],4))

Fail: DCount("[Departure]","[GetStats]","([Departure]<0")
 
BTW vartype(DateDiff("n",FormatDateTime([Trips]!
[Departure
Time],4),FormatDateTime([Runs]![Dep],4))) returns 3,
Long Integer. For whatever good that does you.
-----Original Message-----
Using these two expressions, I'm getting a data type
error on the comparison in the Dcount function. Can
anyone provide the solution? Thank you!

Departure: DateDiff("n",FormatDateTime([Trips]! [Departure
Time],4),FormatDateTime([Runs]![Dep],4))

Fail: DCount("[Departure]","[GetStats]","([Departure]<0")
.
 
The DateDiff() function returns the time difference in minutes so the return
type is a Long. The use of the FormatDateTime() function is unnecessary,
IMHO.

I am not sure what you are trying to do with the DCount() fn since the first
argument of DCount() fn needs to be a Field name in the Domain specified by
the second argument. Do you have a Field "Departure" in the Table/Query
"GetStats"?

Also, the DCount you posted is syntactically incorrect as you have an
unbalanced opening parenthesis.
 
First, thanks for the reply. Both functions are in the
same query "[GetStats]" and "[Departure]" is the label
for the datediff expresion. What I am attempting to
count is the number of negative values in Depature, which
itself is a calculation of Actual Departure-Scheduled
Departure. I am trying to simulate the "Countif"
function in Excel. I removed the FormatDateTime but
there was no change. As the retun type is long, why does
the count return a data type error. I get the same error
when I remove the condition.
-----Original Message-----
The DateDiff() function returns the time difference in minutes so the return
type is a Long. The use of the FormatDateTime() function is unnecessary,
IMHO.

I am not sure what you are trying to do with the DCount () fn since the first
argument of DCount() fn needs to be a Field name in the Domain specified by
the second argument. Do you have a Field "Departure" in the Table/Query
"GetStats"?

Also, the DCount you posted is syntactically incorrect as you have an
unbalanced opening parenthesis.

--
HTH
Van T. Dinh
MVP (Access)


Using these two expressions, I'm getting a data type
error on the comparison in the Dcount function. Can
anyone provide the solution? Thank you!

Departure: DateDiff("n",FormatDateTime([Trips]! [Departure
Time],4),FormatDateTime([Runs]![Dep],4))

Fail: DCount("[Departure]","[GetStats]","([Departure]
<0")


.
 
Sorry, I don't understand your explanation.

Suggest you post relevant Table details, what you want from the Query (or
Queries since [Departure] is an Alias and you cannot use Alias in another
expression in the same Query) and the SQL Strings of your attempted Queries.

Also suggest you check Access VB Help on the DCount() function (see also my
previous post).
 
Back
Top