Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to update a field based on a value entered in another field? 2

Status
Not open for further replies.

UongSaki

Technical User
Nov 15, 2003
65
0
0
US
I have a table with two date fields, date1 & date2. How dow I get Date2 automatically entered for me when I enter Date1 by adding 15 days to Date1? I was able to have Date2 entered automatically on a form but was not able to have it updated in the table.

Thanks,

UongSaki
 
Why storing derived/calculated values ?
Anyway in the form the ControlSource property of the Date2 control should be the Date2 field and in the AfterUpdate event procedure of the Date1 control:
Me![Date2] = Me![Date1] + 15

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
In a form based on (all the fields in) your table, you use the AfterUpdate event of the Date1 control to run code to fill in Date2.

The code you want is:

me.date2 = me.date1 +15

To get to the correct place to add this line you do this:
right-click on the date1 control and choose properties.
In the Event tab, click into the Afterupdate event.
Now click the Build (...) button to the right and when you are asked choose Code Procedure.

This now places you in the code procedure .




 
Um, too vage the info you give. You might need to add 15 to the serial conversion of the date, then transform it again to date, simply by nesting the functions.
If you want it the hard way, you could make a public function that returns the 15 days later date and use it in the textbox, like =DateFunction(Date1) or even make a function that receives the date and the number of days to add, like =DateFunction(Date1,15). But if you could give more info it'd be easier.
Meditate on this, I will...

To boldly code, where no programmer has compiled before!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top