Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Having Difficulties with DLOOKUP or JOIN in Access

Posted on 2008-06-25
8
Medium Priority
?
415 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 2000 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Suggested Courses

963 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