Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2014-01-19
3
Medium Priority
?
479 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 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 66

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

670 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