Auto Increase date field

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I have aged failed in a table that get initialize during initial data load.
I would like for this field to increase by one each day goes by. This field
is locked on the form level.

The initial code for loading the field as follow:
Aged = DateDiff("d",[Date On File],Date())

I have tried to update this automatically on the form level by:
On Enter: Me.[Aged]= DateDiff("d",[Date On File],Date())
Or
On load: Me.[Aged]= DateDiff("d",[Date On File],Date())
Or
Before update: Me.[Aged]= DateDiff("d",[Date On File],Date())

I have Un-locked the field and re-try the above codes, but no auto
update…………..

Regards
 
You have a field named Aged, that should *always* be the number of days
between the [Date On File] field and today?

If so, you can save yourself all the trouble of trying to keep it up to date
like this:
1. Remove the field from your table.

2. Create a query using this table, and type this into a fresh column in the
Field row:
Aged: DateDiff("d",[Date On File],Date())

3. Change the Record Source property of your forms and reports so they use
the query instead of the table.

The query calculates the field when needed, so it is always right, every
day, and there's nothing more to do.

More information:
http://allenbrowne.com/casu-14.html
 
Thank you Allen.............That worked

Allen Browne said:
You have a field named Aged, that should *always* be the number of days
between the [Date On File] field and today?

If so, you can save yourself all the trouble of trying to keep it up to date
like this:
1. Remove the field from your table.

2. Create a query using this table, and type this into a fresh column in the
Field row:
Aged: DateDiff("d",[Date On File],Date())

3. Change the Record Source property of your forms and reports so they use
the query instead of the table.

The query calculates the field when needed, so it is always right, every
day, and there's nothing more to do.

More information:
http://allenbrowne.com/casu-14.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

sap4ora said:
Hello,

I have aged failed in a table that get initialize during initial data
load.
I would like for this field to increase by one each day goes by. This
field
is locked on the form level.

The initial code for loading the field as follow:
Aged = DateDiff("d",[Date On File],Date())

I have tried to update this automatically on the form level by:
On Enter: Me.[Aged]= DateDiff("d",[Date On File],Date())
Or
On load: Me.[Aged]= DateDiff("d",[Date On File],Date())
Or
Before update: Me.[Aged]= DateDiff("d",[Date On File],Date())

I have Un-locked the field and re-try the above codes, but no auto
update…………..

Regards
 
Back
Top