By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,714 Members | 1,205 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,714 IT Pros & Developers. It's quick & easy.

How do you calculate a date on a form?

P: 2

I've designed a form where I'd like users to be able to enter a date into field number one. When they do that, field number two will be populated with a date that is 27 years from the date they entered. How do I go about setting this up?

Will the data in field number two be saved to the corresponding field the table the form is associated with?

Jul 30 '10 #1
Share this Question
Share on Google+
1 Reply

Expert 2.5K+
P: 3,532
Answering the second question first, absolutely not! Most calculated values, and certainly this one, should not be stored in the underlying table but rather simply re-calculated when needed, such as in another form or report. So, with Field2 being Unbound:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Field1_AfterUpdate()
  2.  Me.Field2 = DateAdd("yyyy", 27, Me.Field1)
  3. End Sub
  5. Private Sub Form_Current()
  6.  Me.Field2 = DateAdd("yyyy", 27, Me.Field1)
  7. End Sub
Linq ;0)>
Jul 30 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.