DateDiff Question

G

Guest

I am new to Access and am tryng to use the DateDiff function to calculate and
display the number of days between two dates (ExpectedSeparationDate and
DateChecklistPrepared) on a form I've created called DDForm2648. I have read
as much as I can in the posts related ot DateDiff, but I really don't
understand how to do it and would appreciate some help. As I said, I created
a form that has these two dates expressed as time/date fields. I want to add
a third field that calculates and displays the number of days between.

What I have done so far:
1) In the table design view for the form, which is called DDForm2648, I have
inserted a row and called the Field Name 'DateDiff', in the Data Type, I put
'number' (I didn't type in the ' marks). Then in the field properties box, I
clicked in Default Value and then clicked on the button with the three dots.
I then clicked on the little + to the left of functions and then on the
folder beside Built-In Functions, then Date/Time, then DateDiff and then
clicked paste. Then I changed what appeared in the Expression Builder window
to look exactly like this:
DateDiff ("d"[ExpectedSeparationDate],[DateChecklistPrepared])
I then clicked okay. Then I tried to click the save icon but I get the
following message:
The database engine does not recognize either the field
'ExpectedSeparationDate' in a validation expression, or the default value in
the table 'DDForm2648'.

I'm just shooting in the dark here. I have absolutely no clue what I'm
doing, I'm just trying to follow what I've read in other posts, but it's all
very, very confusing. Can someone please give me ...a simple step by simple
step?
Thank you very much.
 
F

fredg

I am new to Access and am tryng to use the DateDiff function to calculate and
display the number of days between two dates (ExpectedSeparationDate and
DateChecklistPrepared) on a form I've created called DDForm2648. I have read
as much as I can in the posts related ot DateDiff, but I really don't
understand how to do it and would appreciate some help. As I said, I created
a form that has these two dates expressed as time/date fields. I want to add
a third field that calculates and displays the number of days between.

What I have done so far:
1) In the table design view for the form, which is called DDForm2648, I have
inserted a row and called the Field Name 'DateDiff', in the Data Type, I put
'number' (I didn't type in the ' marks). Then in the field properties box, I
clicked in Default Value and then clicked on the button with the three dots.
I then clicked on the little + to the left of functions and then on the
folder beside Built-In Functions, then Date/Time, then DateDiff and then
clicked paste. Then I changed what appeared in the Expression Builder window
to look exactly like this:
DateDiff ("d"[ExpectedSeparationDate],[DateChecklistPrepared])
I then clicked okay. Then I tried to click the save icon but I get the
following message:
The database engine does not recognize either the field
'ExpectedSeparationDate' in a validation expression, or the default value in
the table 'DDForm2648'.

I'm just shooting in the dark here. I have absolutely no clue what I'm
doing, I'm just trying to follow what I've read in other posts, but it's all
very, very confusing. Can someone please give me ...a simple step by simple
step?
Thank you very much.

You're creating an un-necessary problem for yourself.
All you need do is in addition to what ever other fields you may have
in your table, include a field to store the [ExpectedSeparationDate]
and the [DateChecklistPrepared] dates. You do NOT need a field to save
the difference in days data (the [DateDiff] field).

Using a form with this table as it's record source, include the two
date fields, and enter whatever dates you need in the form. Add
another UNBOUND control to the form.
Set it's ControlSource to:

=DateDiff("d",[ExpectedSeparationDate],[DateChecklistPrepared])

As you enter the dates, this control will display the number of days
difference.
You do not need to save this data. Any time you need to show the
difference in days, simply use the same expression and compute it.
 
G

Guest

It worked. Thank you very much.


fredg said:
I am new to Access and am tryng to use the DateDiff function to calculate and
display the number of days between two dates (ExpectedSeparationDate and
DateChecklistPrepared) on a form I've created called DDForm2648. I have read
as much as I can in the posts related ot DateDiff, but I really don't
understand how to do it and would appreciate some help. As I said, I created
a form that has these two dates expressed as time/date fields. I want to add
a third field that calculates and displays the number of days between.

What I have done so far:
1) In the table design view for the form, which is called DDForm2648, I have
inserted a row and called the Field Name 'DateDiff', in the Data Type, I put
'number' (I didn't type in the ' marks). Then in the field properties box, I
clicked in Default Value and then clicked on the button with the three dots.
I then clicked on the little + to the left of functions and then on the
folder beside Built-In Functions, then Date/Time, then DateDiff and then
clicked paste. Then I changed what appeared in the Expression Builder window
to look exactly like this:
DateDiff ("d"[ExpectedSeparationDate],[DateChecklistPrepared])
I then clicked okay. Then I tried to click the save icon but I get the
following message:
The database engine does not recognize either the field
'ExpectedSeparationDate' in a validation expression, or the default value in
the table 'DDForm2648'.

I'm just shooting in the dark here. I have absolutely no clue what I'm
doing, I'm just trying to follow what I've read in other posts, but it's all
very, very confusing. Can someone please give me ...a simple step by simple
step?
Thank you very much.

You're creating an un-necessary problem for yourself.
All you need do is in addition to what ever other fields you may have
in your table, include a field to store the [ExpectedSeparationDate]
and the [DateChecklistPrepared] dates. You do NOT need a field to save
the difference in days data (the [DateDiff] field).

Using a form with this table as it's record source, include the two
date fields, and enter whatever dates you need in the form. Add
another UNBOUND control to the form.
Set it's ControlSource to:

=DateDiff("d",[ExpectedSeparationDate],[DateChecklistPrepared])

As you enter the dates, this control will display the number of days
difference.
You do not need to save this data. Any time you need to show the
difference in days, simply use the same expression and compute it.
 

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