Default value: (Date) - 5 days

I

Iram

Hello. I am using Access 2003 and I when I am adding a new record on a form I
need a field to autopopulate with a default value based upon another field.

"Position Stmnt Due D" needs to be autopopulated based upon what I enter in
"State Hearing Date" minus 5 days.

For example if I put 8/15/08 in "State Hearing Date" I need 8/10/08 to
appear in "Position Stmnt Due D".

Could you help me with this? Where would I put your code?

Thanks.
Iram/mcp
 
K

Klatuu

Since Position Stmnt Due D is a calculated field, it really should not be
stored in the table. It violates database normalization to do so. The
correct method would be to use the following expression in the Control Source
property of Position Stmnt Due D:
=DateAdd("d", -5, [State Hearing Date])

[State Hearing Date] should be the name of the control on your form where
you enter the State Hearing Date.
 
I

Iram

Thanks.
What if I have to have the ability to change the Position Statement Due D?

Iram/mcp


Klatuu said:
Since Position Stmnt Due D is a calculated field, it really should not be
stored in the table. It violates database normalization to do so. The
correct method would be to use the following expression in the Control Source
property of Position Stmnt Due D:
=DateAdd("d", -5, [State Hearing Date])

[State Hearing Date] should be the name of the control on your form where
you enter the State Hearing Date.

--
Dave Hargis, Microsoft Access MVP


Iram said:
Hello. I am using Access 2003 and I when I am adding a new record on a form I
need a field to autopopulate with a default value based upon another field.

"Position Stmnt Due D" needs to be autopopulated based upon what I enter in
"State Hearing Date" minus 5 days.

For example if I put 8/15/08 in "State Hearing Date" I need 8/10/08 to
appear in "Position Stmnt Due D".

Could you help me with this? Where would I put your code?

Thanks.
Iram/mcp
 
K

Klatuu

That is a different situation, then.
Remove the code from the control source and bind the control to a field in
the form's recordset.
Then in the After Update event of the control bound to [State Hearing Date],
populate the control bound to [Position Stmnt Due D]

Me.[txtPosition Stmnt Due D] = DateAdd("d", -5, Me.[txtState Hearing
Date])
--
Dave Hargis, Microsoft Access MVP


Iram said:
Thanks.
What if I have to have the ability to change the Position Statement Due D?

Iram/mcp


Klatuu said:
Since Position Stmnt Due D is a calculated field, it really should not be
stored in the table. It violates database normalization to do so. The
correct method would be to use the following expression in the Control Source
property of Position Stmnt Due D:
=DateAdd("d", -5, [State Hearing Date])

[State Hearing Date] should be the name of the control on your form where
you enter the State Hearing Date.

--
Dave Hargis, Microsoft Access MVP


Iram said:
Hello. I am using Access 2003 and I when I am adding a new record on a form I
need a field to autopopulate with a default value based upon another field.

"Position Stmnt Due D" needs to be autopopulated based upon what I enter in
"State Hearing Date" minus 5 days.

For example if I put 8/15/08 in "State Hearing Date" I need 8/10/08 to
appear in "Position Stmnt Due D".

Could you help me with this? Where would I put your code?

Thanks.
Iram/mcp
 
I

Iram

Thanks Again.
You are the man!


Iram/mcp



Klatuu said:
That is a different situation, then.
Remove the code from the control source and bind the control to a field in
the form's recordset.
Then in the After Update event of the control bound to [State Hearing Date],
populate the control bound to [Position Stmnt Due D]

Me.[txtPosition Stmnt Due D] = DateAdd("d", -5, Me.[txtState Hearing
Date])
--
Dave Hargis, Microsoft Access MVP


Iram said:
Thanks.
What if I have to have the ability to change the Position Statement Due D?

Iram/mcp


Klatuu said:
Since Position Stmnt Due D is a calculated field, it really should not be
stored in the table. It violates database normalization to do so. The
correct method would be to use the following expression in the Control Source
property of Position Stmnt Due D:
=DateAdd("d", -5, [State Hearing Date])

[State Hearing Date] should be the name of the control on your form where
you enter the State Hearing Date.

--
Dave Hargis, Microsoft Access MVP


:

Hello. I am using Access 2003 and I when I am adding a new record on a form I
need a field to autopopulate with a default value based upon another field.

"Position Stmnt Due D" needs to be autopopulated based upon what I enter in
"State Hearing Date" minus 5 days.

For example if I put 8/15/08 in "State Hearing Date" I need 8/10/08 to
appear in "Position Stmnt Due D".

Could you help me with this? Where would I put your code?

Thanks.
Iram/mcp
 

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