Solved

Dlookup

Posted on 2011-09-25
5
409 Views
Last Modified: 2012-05-12
I am using the below on Dlookup to no avaii:

JckRank:  dllookup([Rank], "JckRanks", "AthroughB.[Jockey] = "Ranks.[Jck]")

I am trying to get the ranks of a jockey from a table called JckRanks as below:

Jock           Rank
Smith            1
Gomez          2
Solis             3
Nakatani      4
Velasquez   5

In another Table named AthroughB, there is a column named Jockey.

In this query, I am trying to get the name of the jockey from  table AthroughB and get the rank of that jockey from table JckRanks.  For Example if the jockey name in the column named Jockey from table AthroughB is Nakatani, I want the query to get  the rank  of 4.  There are 1800 named jockeys.
0
Comment
Question by:JackJackson54
[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
  • 2
  • 2
5 Comments
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
ID: 36595436

So, how about something like:

SELECT AthroughB.*, JckRanks.Rank
FROM AthroughB
LEFT JOIN JckRanks
ON AthroughB.Jockey = JckRanks.Jockey

Normally, I would use in autonumber (ID) field as the primary key of the AthroughB table and use that ID as the foreign key in my JckRanks table.  Trying to join on a name (I assume that [Jockey] field is a name) will be a problem with that many jockeys.
0
 
LVL 42

Expert Comment

by:dqmq
ID: 36595442
>I am trying to get the name of the jockey from  table AthroughB and get the rank of that jockey from table JckRanks.

dlookup only returns one value, not two.  For example, you can get a jockey's rank like this:


dlookup([Rank], "JckRanks", "[Jock] = ""Nakatani""")
0
 

Author Comment

by:JackJackson54
ID: 36595445
The Jockey name changes from each row.
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 36595499

If you don't like my query recommended above, you could try:

SELECT AthroughB.*, DLOOKUP("Rank", "JckRanks", "[Jock] = """ & AthroughB.[Jockey] & """") as JockRank
FROM AthroughB
0
 

Author Comment

by:JackJackson54
ID: 36595522
Thanks Fyed, the first one worked and worked great.  I have spent 2 hours trying to get mine to work
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up 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.

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

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