M
mustish1 via AccessMonster.com
Hi:
How to i union both queries. Both queries match record from tabl tech_id.
This is the result which i need. First 2nd query run and match with table
tech_id. If it match then it print AccountNum from first table also. If it
dont match then first query run as first query must be match with table
tech_id and print that result. Both tables (tbl_PPVResearch,
tbl_ValidDisputes) have same field TicketNum. If both table match then 2nd
query shows the Techcont. If its not possible thru query or any other way by
using VBScript.
Output
------
TicketNum, AccountNum, OtherAcct1, OtherAcct2, OtherAcct3, LstVldTech,
TechCont
Query-1
SELECT tbl_PPVResearch.TicketNum, tbl_PPVResearch.AccountNum, tech_id.
TECHCONT, tech_id.CORP, tech_id.CORP,
tbl_ValidDisputes.LstVldTech, tech_id.TECH
FROM tech_id, tbl_ValidDisputes INNER JOIN tbl_PPVResearch ON
tbl_ValidDisputes.TicketNum = tbl_PPVResearch.TicketNum
WHERE (((tech_id.CORP)=Val(Left(nz([tbl_PPVResearch].[AccountNum],0),5))) AND
((tbl_ValidDisputes.LstVldTech)=[tech_id].[tech]))
GROUP BY tbl_PPVResearch.TicketNum, tbl_PPVResearch.AccountNum, tech_id.
TECHCONT, tech_id.CORP, tech_id.CORP,
tbl_ValidDisputes.LstVldTech, tech_id.TECH;
Query-2
SELECT [tbl_ValidDisputes].[TicketNum], [tbl_ValidDisputes].[OtherAcct1],
[tbl_ValidDisputes].[OtherAcct2],
[tbl_ValidDisputes].[OtherAcct3], [tbl_ValidDisputes].[LstVldAccount],
[tech_id].[TECH], [tech_id].[TECHCONT],
[tech_id].[CORP]
FROM tbl_ValidDisputes LEFT JOIN tech_id ON
([tech_id].[corp]=NZ(Switch(nz([tbl_ValidDisputes].[LstVldAccount])
="OtherAccount
1",Val(Left(nz([tbl_ValidDisputes].[OtherAcct1],0),5)),Nz([tbl_ValidDisputes].
[LstVldAccount])="OtherAccount
2",Val(Left(nz([tbl_ValidDisputes].[OtherAcct2],0),5)),nz([tbl_ValidDisputes].
[LstVldAccount]="OtherAccount
3"),Val(Left(nz([tbl_ValidDisputes].[OtherAcct3],0),5))))) AND (
[tbl_ValidDisputes].[LstVldTech]=[tech_id].[tech]);
TicketNum, AccountNum, OtherAcct1, OtherAcct2, OtherAcct3, LstVldTech,
TechCont
Thanks.
How to i union both queries. Both queries match record from tabl tech_id.
This is the result which i need. First 2nd query run and match with table
tech_id. If it match then it print AccountNum from first table also. If it
dont match then first query run as first query must be match with table
tech_id and print that result. Both tables (tbl_PPVResearch,
tbl_ValidDisputes) have same field TicketNum. If both table match then 2nd
query shows the Techcont. If its not possible thru query or any other way by
using VBScript.
Output
------
TicketNum, AccountNum, OtherAcct1, OtherAcct2, OtherAcct3, LstVldTech,
TechCont
Query-1
SELECT tbl_PPVResearch.TicketNum, tbl_PPVResearch.AccountNum, tech_id.
TECHCONT, tech_id.CORP, tech_id.CORP,
tbl_ValidDisputes.LstVldTech, tech_id.TECH
FROM tech_id, tbl_ValidDisputes INNER JOIN tbl_PPVResearch ON
tbl_ValidDisputes.TicketNum = tbl_PPVResearch.TicketNum
WHERE (((tech_id.CORP)=Val(Left(nz([tbl_PPVResearch].[AccountNum],0),5))) AND
((tbl_ValidDisputes.LstVldTech)=[tech_id].[tech]))
GROUP BY tbl_PPVResearch.TicketNum, tbl_PPVResearch.AccountNum, tech_id.
TECHCONT, tech_id.CORP, tech_id.CORP,
tbl_ValidDisputes.LstVldTech, tech_id.TECH;
Query-2
SELECT [tbl_ValidDisputes].[TicketNum], [tbl_ValidDisputes].[OtherAcct1],
[tbl_ValidDisputes].[OtherAcct2],
[tbl_ValidDisputes].[OtherAcct3], [tbl_ValidDisputes].[LstVldAccount],
[tech_id].[TECH], [tech_id].[TECHCONT],
[tech_id].[CORP]
FROM tbl_ValidDisputes LEFT JOIN tech_id ON
([tech_id].[corp]=NZ(Switch(nz([tbl_ValidDisputes].[LstVldAccount])
="OtherAccount
1",Val(Left(nz([tbl_ValidDisputes].[OtherAcct1],0),5)),Nz([tbl_ValidDisputes].
[LstVldAccount])="OtherAccount
2",Val(Left(nz([tbl_ValidDisputes].[OtherAcct2],0),5)),nz([tbl_ValidDisputes].
[LstVldAccount]="OtherAccount
3"),Val(Left(nz([tbl_ValidDisputes].[OtherAcct3],0),5))))) AND (
[tbl_ValidDisputes].[LstVldTech]=[tech_id].[tech]);
TicketNum, AccountNum, OtherAcct1, OtherAcct2, OtherAcct3, LstVldTech,
TechCont
Thanks.