Solved

Having Difficulties with DLOOKUP or JOIN in Access

Posted on 2008-06-25
8
393 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

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

Suggested Solutions

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of utilizing SQL Server stored procedures 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 Micr…
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…

776 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