Solved

How populate two field on a form using data entered in 1st field

Posted on 2014-01-19
3
452 Views
Last Modified: 2014-01-19
I have three fields on a form.

Field #1 is a combobox from which a user can select a year.  For example, "2013"

Fields #2 and #3 are fields which I want to populate on the afterupdate event of field #1.

If the user selected 2013 from field #1, I want field #2 to populate with "7/1/2013"  (It will always be July 1st).

and

If the user selected 2013 from field #1, I want field #3 to populate with "6/30/2014"  (one year after field #2).

How can this be done?
0
Comment
Question by:SteveL13
3 Comments
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 39792287
place the codes in the afterupdate event of the combo

me.field2=dateserial(me.field1,7,1)

me.field3=dateserial(me.field1+1,7,0)
0
 

Author Closing Comment

by:SteveL13
ID: 39792311
Perfect!  Thanks again.
0
 
LVL 65

Expert Comment

by:Jim Horn
ID: 39792312
The above answer is correct.  Also, what I typically see is if a business has years that follow certain logic, such as 7/1/XX to 6/30/XX + 1, then there should be a table that stores all of these values, such that any year logic can use the table without having to recalculate it every time.

Or in the case of this combo box, bring along for the combo box row list the two date columns, then in VBA the Combo Box's AfterUpdate event can just do a

Me.SomeTextBox = Me.MyComboBox.Column(x-1), where x is the ordinal position of the row, meaning if StartDate is the 5th row then a 4 would go here.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now