Solved

Access 97: DLookup Query Criteria Question

Posted on 2003-11-06
6
430 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 250 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
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: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 250 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

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!

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

705 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