Calculate a field value based on another field

S

So Call Me Crazy

I've got a table that contains a date (that the user can modify or leave as
default of today). That same record has another date field (expiration date)
that is calculated based on the value of the original date field.

Access won't allow me to set the default value of the expiration date within
the table definition by using the value of another field. So, I've got it
defaulting to calculating based on Now().

So, I'm trying to do it in code. I've tried AfterUpdate and OnChange, but
it isn't working. Not getting an error, it just isn't changing.

TIA
 
F

fredg

I've got a table that contains a date (that the user can modify or leave as
default of today). That same record has another date field (expiration date)
that is calculated based on the value of the original date field.

Access won't allow me to set the default value of the expiration date within
the table definition by using the value of another field. So, I've got it
defaulting to calculating based on Now().

So, I'm trying to do it in code. I've tried AfterUpdate and OnChange, but
it isn't working. Not getting an error, it just isn't changing.

TIA

You don't need to store the calculated expiration date value.
As long as you have the Original Date stored, any time you need the
expiration date, calculated it. That's the correct way to use Access.

In the control source of an unbound control on a form or in a report:

=DateAdd("d",90,[OriginalDate])

will add 90 days to the Original Date.
But do not store this value!
 
S

So Call Me Crazy

You are SO right! Thank you for that insight!

fredg said:
I've got a table that contains a date (that the user can modify or leave as
default of today). That same record has another date field (expiration date)
that is calculated based on the value of the original date field.

Access won't allow me to set the default value of the expiration date within
the table definition by using the value of another field. So, I've got it
defaulting to calculating based on Now().

So, I'm trying to do it in code. I've tried AfterUpdate and OnChange, but
it isn't working. Not getting an error, it just isn't changing.

TIA

You don't need to store the calculated expiration date value.
As long as you have the Original Date stored, any time you need the
expiration date, calculated it. That's the correct way to use Access.

In the control source of an unbound control on a form or in a report:

=DateAdd("d",90,[OriginalDate])

will add 90 days to the Original Date.
But do not store this value!
 

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