Solved

Having Difficulties with DLOOKUP or JOIN in Access

Posted on 2008-06-25
8
404 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
Do you have a plan for Continuity?

It's inevitable. People leave organizations creating a gap in your service. That's where Percona comes in.

See how Pepper.com relies on Percona to:
-Manage their database
-Guarantee data safety and protection
-Provide database expertise that is available for any situation

 

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

What is a Denial of Service (DoS)?

A DoS is a malicious attempt to prevent the normal operation of a computer system. You may frequently see the terms 'DDoS' (Distributed Denial of Service) and 'DoS' used interchangeably, but there are some subtle differences.

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 Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

617 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