How do I merge two queries in vb?

Phonesa

Registered User.
Local time
Today, 10:43
Joined
Jul 3, 2003
Messages
27
I have 3 tables:

Aliases: DefendantID, Alias
Defendant: DefendantID, Name
Citations: CitationNo, DefendantID, CitationDetails

I created two queries and they sort of work ...

1) In my first query, I do a union between Aliases and DefendantID to get all the DefendantIDs for a defendant.

qryFindAlias:
Select defendantid
From defendant
where defendantid = "TBTRoberts"
UNION
select alias from aliases
where defendantid = "TBTRoberts";

Problems with qryFindAlias: I need to set it up so I can pass a control from my form rather than a hardcoded value.

2) In my next query, I select from Defendant, Citations, and qryFindAlias

qryAllCitations:
Select C.CitationNo, C.DefendantID, C.CitationDetails, D.Name
FROM (Defendant D INNER JOIN Citations C ON D.DefendantID=C.DefendantID) INNER JOIN qryFindAlias ON D.DefendantID=Alias.defendantid;

I get confused with join sometimes, so using where clause: FROM defendant d, citation c, alias
where d.defendantid = c.defendantid
and alias.defendantid = d.defendantid

Is what I'm attempting to do even possible?
 
Phonesa,

1) In the criteria of your query:

=Forms![YourForm]![DefendantID]

2) When you are in design view, right-click on the line
that joins your tables and select properties. This should
give you more insight. Also, when your query does what you
want, right-click and select SQL view.

Wayne
 
That worked very well. Thank you! :)
 

Users who are viewing this thread

Back
Top Bottom