?
Solved

Access 97: DLookup Query Criteria Question

Posted on 2003-11-06
6
Medium Priority
?
433 Views
Last Modified: 2007-12-19
To keep it short: I have a Query where I am trying to set up DLookup criteria based on the following tables and headers (simplified):

table 1: ID, topic, location, team
table 2: ID, topic, location
table 3: team, topic, location

Basically in my criteria I want to return the following:
if the ID in table 1 = the ID in table 2 return the topic from table 2; if not, but if team in table 1 = team in table 3, return the topic in table 3

I'll need to do something similar for location, but I should be able to figure it out based on the response.

Thanks in advance
0
Comment
Question by:TheJMan
[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
  • 3
  • 2
6 Comments
 
LVL 32

Expert Comment

by:jadedata
ID: 9694974
Hey TheJMan!

  Are you sure you don't want to just link in the appropriate tables??
  Djunk() functions are slow.  And compound that with using them as an expression in a column, where they have to run ONCE FOR EACH RECORD, slower.  Compound that with creating three such expression columns, SLOWEST!

  I would recommend that you use JOINs in the query to achieve this.

regards
Jack
0
 
LVL 18

Assisted Solution

by:bonjour-aut
bonjour-aut earned 1000 total points
ID: 9694995
3 little qeries:

qry1 - does 1st condition

SELECT tab1.ID, tab2.topic
FROM tab1 INNER JOIN tab2 ON tab1.ID = tab2.ID;

qry2 -  does 2nd, where 1st is null

SELECT tab1.ID, tab3.topic
FROM (tab1 INNER JOIN tab3 ON tab1.team = tab3.team) LEFT JOIN tab2 ON tab1.ID = tab2.ID
WHERE (((tab2.ID) Is Null));

qryfinal - does a UNION of above

SELECT * FROM qry1
UNION SELECT * FROM qry2;

could be also done in one with subqueries, but seperate version will also run on A97

regards, Franz
0
 

Author Comment

by:TheJMan
ID: 9695262
Thanks for the reply's.   Franz, I am pretty weak with SQL statements.  For your query one example where table 1 = "master table" and table 2 = "Learning Fair Presenter Lookup" I wrote the following in the criteria box under field = ID and table = master table in my (select) query:

=INNER JOIN [Learning Fair Presenter Lookup] ON [master table].[ID]=[Learning Fair Presenter Lookup].[ID]

As you are probably guessing, it didn't work. Is it a formatting issue or am I way off base?

I may follow up again on the left join and union queries b/c I've never constructed SQL statement queries before

Thanks again
0
Industry Leaders: 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:TheJMan
ID: 9695382
Franz, I think I'm getting closer on query 1 (see below): but I still get a syntax error

SELECT master table.ID, Learning Fair Presenter Lookup.ID
FROM master table INNER JOIN Learning Fair Presenter Lookup
ON master table.ID = Learning Fair Presenter Lookup.ID
0
 

Author Comment

by:TheJMan
ID: 9695408
Got it working on number 2
0
 
LVL 18

Accepted Solution

by:
bonjour-aut earned 1000 total points
ID: 9695523
so do you need further support on that ?

if it helps, download this little example :

http://www.tplus.at/~sissi-franz/test/topics.mdb

the UNION query cannot be looked at in design mode, SQL only

Regards, Franz
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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
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…
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

777 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