Lookup from on tanle adding to another

jcaptchaos2

Well-known Member
Joined
Sep 24, 2002
Messages
1,032
Office Version
  1. 365
Platform
  1. Windows
I need some help with a lookup, in excel for me it is very easy but am struggling here with access. Here is what I want to do, I have a table named employee listing and the columns are employee #, Employee Name, Department and Shift. I have a user form that data is being entered into that goes into another table, I want to add a column to that table that looks at the employee # that was entered and brings over the shift number. I use the vlookup formula all the time in excel so I thought I could figure it out but no luck, could someone give me some advice?
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
If you base the form on a query that uses the 2 tables, joined on Employee #, you should just get the value when you add that field to the form. The advantage of doing this is that the data is only stored in one place so you don't get inconsistencies.
You can also use a combo box to look up the Employee #, and push data from its columns into the appropriate fields. This is typically used in ordering systems where you may want to offer a client a discount without affecting the normal price; and you don't want price increases to affect historical data.
Assuming that
1. MyCombo has Employee #, Full Name, Shift as the 3 columns.
2. You want to push Shift into another control (txtShift).
The AfterUpdate code for the combo would look like this:

Me.txtShift = Me.MyCombo.Column(2)

Note that column numbers start from 0, so Column(2) is actually the third column.

Denis
 
Upvote 0
Sydney,

Thanks for the advice, I am very novice in Access and can not seem to get either to work, I am much better in excel so maybe if I put how I would do it in excel down you could tell me if it is possible to do it in access that way. In this example my employee number that is in my table 1 would be in B9 in the example below, A1:D100 would be my table 2 employee listing table and in that table the 4th column over would have the shift # in it. Is it not possible to pull data into a table from another table by using this sort of code? or it may be easier the way your explaining and I just don't understand it.

Code:
=vlookup(B9,A1:D100,4,false)
 
Upvote 0
I will try to explain a little better, I have a form that has 3 text boxes on it the first one named "Employee Number" the person scans their employee badge, the other 2 text boxes are auto one has the time =Time() and one has the date =Date() so the only thing the person does with this form is scan their badge. The information from this form goes to a table Named "Payroll Time On" That table has "Employee Number", "Time On' and "Date" I am trying to add a column with a lookuo that would look at the employee number in the Payroll Time On table and then find it in a table named "Employee Listing Jac" and grab the 4th colum over which is the shift number. Seems like it should be easy to do but I am making a mess out of it.
 
Upvote 0

Forum statistics

Threads
1,224,542
Messages
6,179,424
Members
452,914
Latest member
echoix

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top