Solved

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

Posted on 2014-01-19
3
455 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 120

Accepted Solution

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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
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.

777 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