I really appreciate the trouble you have gone through. The last two
suggestions do not work either, so I guess I'll just go with the
"convoluted"
queries to do the calculations, if that's OK with you. If you would like
to
experiment further, I'd be happy to send you the database for you to play
with. It's up to you.
Thanks again.
--
Burt
:
I think your date format is confusing ACCESS when using the expression
that
I suggested. Try this expression as the Control Source:
=DateDiff("d",DMax("ChronTransDate","ChronTransfusion","ChronTransDate<"
&
[ChronTransDate]),[ChronTransDate])
If that doesn't work either, then let's add an extra textbox to your
form's
Detail section, and make its Control Source this expression:
=DMax("ChronTransDate","ChronTransfusion","ChronTransDate<" &
[ChronTransDate])
This will let us see what ACCESS is returning for the "previous date
value".
--
Ken Snell
<MS ACCESS MVP>
It is a DateTime field. Here is the code you gave me for the
calculation:
=DateDiff("d",DMax("ChronTransDate","ChronTransfusion","ChronTransDate<#"
&
Format([ChronTransDate],"mm\/dd\/yyyy") & "#"),[ChronTransDate])
When the first date =3/3/7, calculated field is naturally blank.
When the next date =3/13/7, the calc field shows 6, not 10
When the next date = 4/14/7, the calc field shows 2, not 32
When the next date = 4/16/7, the calc field shows 2
When the next date = 4/26/7, the calc field shows 2, not 10
When the next date = 7/25/7, the calc field shows 18, not 90
I'm as puzzled as you are. Thanks again.
--
Burt
:
What is the data type of the "ChronTransDate" field? If it's a
DateTime
type, the DateDiff will work. If it's something else, then it will
fail
at
times. You should be using a DateTime data type field in the table.
--
Ken Snell
<MS ACCESS MVP>
Thanks again for your quick reply. I tried your suggestion. It
only
works
some of the time. Below are 3 columns, date, my number calculated
with
a
series of convoluted queries, and the txtdiff field. It's ok as
long
as
it
doesn't jump a month.
03-Mar-07 0
13-Mar-07 10 10
27-Mar-07 14 14
27-Apr-07 31 13
01-May-07 4 4
05-May-07 4 4
06-Jun-07 32 20
I tried another set with the same anamolous results.
03-Mar-07 0 0
07-Mar-07 4 4
05-Apr-07 29 1
12-Apr-07 7 7
24-Apr-07 12 10
24-May-07 30 7
What do you think is the problem?
--
Burt
:
Add a textbox to the form's Detail section; name it txtDiff. Use
this
expression as its ControlSource:
=DateDiff("d", DMax("ChronTransDate", "ChronTransfusion",
"ChronTransDate<#"
& Format([ChronTransDate],"mm\/dd\/yyyy") & "#"),
[ChronTransDate])
--
Ken Snell
<MS ACCESS MVP>
The form's source is
SELECT ChronTransfusion.ChronTransfusionID,
ChronTransfusion.PatientID,
ChronTransfusion.ChronTransReason,
ChronTransfusion.ChronTransDate,
ChronTransfusion.ChrontransDateNumber,
ChronTransfusion.ChronTransDateFromPeriod,
ChronTransfusion.PatientWeightLB,
ChronTransfusion.PatientWeightKilo,
ChronTransfusion.[ChronTransAmount(ml/kg)],
ChronTransfusion.ChronTransHbPreTx
FROM ChronTransfusion;
What I need to calculate is the period of days between the last
transfusion
date and the one immediately prior.
Thanks for your Rapid Response.
--
Burt
:
You'll need to give us more details about the query that is the
form's
RecordSource -- SQL statement would be good as a starting
point.
--
Ken Snell
<MS ACCESS MVP>
message
Using a continuous form, I have a date field which indicates
an
action.
The
next time an action occurs, a new date is entered (on a new
line
in
the
form). How would I calculate the number of days between the
two
actions?
I'd appreciate any help. Thanks