Solved

Access 97: DLookup Query Criteria Question

Posted on 2003-11-06
6
421 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
  • 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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
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…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

762 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now