Solved

Text box auto populate based on combo box in Access 2007

Posted on 2014-09-03
1
476 Views
Last Modified: 2014-09-08
So it has been a while since I worked in Access so I am very rusty. Here is the scenario:

Employee table with your basic data - fname, lname, empid, payrate and some others
Time entry table that has several fields including empid and payrate.

In the time entry form I have a combo box that is populated by a query allowing you to choose the employee you will be entering time for.

My problem - When I choose the employee I want the payrate text box to auto-populate with the payrate from the employee table. That information will in turn be placed in the payrate field of the time entry table.

Before you ask - Yes the payrate will be included in both tables but I want to be able to record in the time entry table how much they were being paid at the time of the entry.

Thanks in advance for any help.
0
Comment
Question by:princeservice
1 Comment
 
LVL 34

Accepted Solution

by:
PatHartman earned 500 total points
ID: 40301696
If the payrate is associated with an employee, then include the payrate in the query used to populate the combo (don't forget to update the column count and column widths after you add the new column).  Then in the AfterUpdate event of the combo -

Me.txtPayRate = Me.CboEmployee.Column(2)

The columns of a combo are a zero-based array.  So .Column(2) is referring to the third column.  I assumed -
EmpID, EmpName, PayRate were the three columns.  Adjust the column number accordingly if you have more than three columns.
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

911 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

21 Experts available now in Live!

Get 1:1 Help Now