Look up data from another table

posfog

Board Regular
Joined
Jun 2, 2009
Messages
171
Hi all,
I am fairly new to Access and need some help or assistance in creating what would be a Vlookup if done in excel.

What i have so far is two tables within the same access database

Table one name Data
Table two name Costs

When someone selects a certain Material Part Number i want the lookup to look at this column in the "Data" table called and find that same number in the "Cost" table and to display the price which is also shown next to the Material Part Number within the Cost table in another cell within the same Data table

I think once i may have it explained i should be ok to work on this for other look ups that i need to do within the same database.

Hope somone can help and point me in the right direction.

Regards
 
A few more questions.
- What Data Type is this Part Number field? Is it Text or Numeric?
- Is this for an Entry Form, or a form to review Existing Data (or both)?
 
Upvote 0

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
AFAIAA you only need [] if the names have spaces in them.?

This below works fine on my form
Code:
=DSum("Amount","Emails","CMS = " & [CMS] & " AND ID <=" & [ID])

Try
Code:
=DLookUp("Price","Cost","[Material Part Number]=" & [Material Part Number])

This assumes that the Material Part Number is numeric?

if text then
Code:
=DLookUp("Price","Cost","[Material Part Number]='" & [Material Part Number] & "'")

HTH
 
Upvote 0
none of those worked then Welshgasman

Sorry for sounding dumb but if i did this in excel the formula would be

=VLOOKUP(A19,Cost!B:C,2,FALSE)

Look at A19 (which would be my Material Part Number on my form)

Look at cost table for material part number and bring back the price


All i got in at moment is a #ERROR

Even looked for a template online that has a working dlookup built in to see if i can understand it

 
Upvote 0
The devil is always in the details. Please answer the questions I asked in my previous post.
A few more questions.
- What Data Type is this Part Number field? Is it Text or Numeric?
- Is this for an Entry Form, or a form to review Existing Data (or both)?
These details matter, and affect how you need to write the formula (or if you should be using a query instead of a DLOOKUP).
 
Upvote 0
In this kind of scenario I would consider changing your text box to a combo box for the control[Material Part Number], with the Record Source of the Combo being:

Code:
Select [Material Part Number], [Price] From Cost

Then set the Price text box to: =[Material Part Number].[column](1) (combo starts at column 0) - the benefits of this are that it will normally run faster than Dlookup, you can change the query of the combo to return more fields which can then be used without an additional dlookup overhead and limit the parts that can be selected and also improve your data quality.
 
Upvote 0
The devil is always in the details. Please answer the questions I asked in my previous post.

These details matter, and affect how you need to write the formula (or if you should be using a query instead of a DLOOKUP).

Hi Joe4

Part number field is a Alphanumeric

EG
Material Part Number
8W936568AA
9W839J447CD
DPLA12B637CE


And i am trying to get this to work on the form section where people will be entering the data

Hope this helps
 
Upvote 0

Here is a sample
showing both the lookup and combo methods.

If you are likely to have more than one Dlookup on the form from the one table I would definitely recommend using the combo box.

Thanks Stumac - i will go away now and look in detail on how this example works and let you all know how i get on
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,200
Members
453,022
Latest member
RobertV1609

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