Solved

Having Difficulties with DLOOKUP or JOIN in Access

Posted on 2008-06-25
8
388 Views
Last Modified: 2011-09-20
Tried to  mimic  excel VLOOKUP does  by using a JOIN (LEFT JOIN) does but it seems to be creating duplicates!  i then thought of using DLOOKUP - but I am having difficulties

I would like :

Expr1: DLookUp([qry14].[Cust_ID],[New_Customers],[qry14].[Cust_ID]=[qry14].[New_Customers]

??



0
Comment
Question by:7601105166084
  • 4
  • 4
8 Comments
 
LVL 11

Expert Comment

by:SeanStrickland
ID: 21866598
Try:

Expr1: DLookUp("[qry14].[Cust_ID]","[New_Customers]","[qry14].[Cust_ID]=[qry14].[New_Customers]"
0
 
LVL 11

Accepted Solution

by:
SeanStrickland earned 500 total points
ID: 21866641
I'm sorry, please add the ) at the end.  The DLookup parameters have to be in quotes.  You may have to try the second one, also.

Expr1: DLookUp("[qry14].[Cust_ID]","[New_Customers]","[qry14].[Cust_ID]=[qry14].[New_Customers]")


Expr1: DLookUp("[qry14].[Cust_ID]","[New_Customers]","[qry14].[Cust_ID]=" & [qry14].[New_Customers] & ")
0
 

Author Comment

by:7601105166084
ID: 21866739
I know with a JOIN both 'entities' have to be present  but with Dlookup what should i do?

Sorry it looks like I posted the wrong statement at first !!
I'm  tryin to say:

Select the customerID from New_Customers Where qry14.Cust_ID = NewCustomers.Cust_ID -
- hope this makes sense now. ((--
0
 

Author Comment

by:7601105166084
ID: 21872862
I picked up a great word from here the other day its called aircode.

Is there a reason why im not getting any replies now?

0
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 11

Expert Comment

by:SeanStrickland
ID: 21873487
DLookup is simply going to look at the recordset that the query is displaying, and show you the field you're requesting (first criteria) from the table you're looking at (second criteria), where your requirements in the third criteria match.

Looking back over that code, you're pulling completely from a query called "qry14", so you would want your DLookup to look this way:

Expr1: DLookup("Cust_ID","qry14","[Cust_ID]=" & [New_Customers] & ")

If New_Customers was an integer (which I'm assuming) that equaled 10, the code would actually be translated to this at run-time:
DLookup("Cust_ID","qry14","[Cust_ID]=10")


But why would you put that in a query (I'm assuming you are because you have Expr1: before it)?  In a query, you would simply use a JOIN statement like what you're saying.  From Design View, drag Cust_ID from qry14 (?) onto the New_Customers field in your New_Customers table to JOIN them, then add Cust_ID to your query and add whatever items you want to pull from the New_Customers table.  This is called an INNER JOIN.  It will only pull items where you have a matching Cust_ID and New_Customer field.

You can also use LEFT JOIN and RIGHT JOIN, where a join like that will show you all fields from one of your tables and will relate any matching entries from the other table.

You can change this by double-clicking the line that appears after you join the two fields in design view.  It will give you three options on how the join should act, and clearly states what each does.
0
 

Author Comment

by:7601105166084
ID: 21881882
Apologies for my delay..

Is it right to say that i can accomplish the same thing with a DLOOKUP or a JOIN but need to have the neccessaary requirements place first i.e a join between the two tables.. first

0
 
LVL 11

Expert Comment

by:SeanStrickland
ID: 21885793
That is correct.
0
 

Author Closing Comment

by:7601105166084
ID: 31470598
You did give me the correct syntax - which is what i did ask for initially
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

762 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

24 Experts available now in Live!

Get 1:1 Help Now