Solved

Having Difficulties with DLOOKUP or JOIN in Access

Posted on 2008-06-25
8
400 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

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
 
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

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…

734 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