Did You Expect Like this Result ? just Example i use only SQL and Temp tables for beter Understanding the concepts ........
Declare @Combobox1 NVARCHAR(30)
Declare @Combobox2 NVARCHAR(30)
SET @Combobox1='@TestTbl1'
SET @Combobox2='@TestTbl2'
Declare @TestTbl1 AS Table (Id Int,Name NVARCHAR(20))
Declare @TestTbl2 AS Table (Id Int,Name NVARCHAR(20))
Declare @TestTbl3 AS Table (Id Int,Name NVARCHAR(20))
INSERT INTO @TestTbl1 (Id,Name) VALUES (1,'A')
INSERT INTO @TestTbl1 (Id,Name) VALUES (2,'B')
INSERT INTO @TestTbl1 (Id,Name) VALUES (3,'C')
INSERT INTO @TestTbl1 (Id,Name) VALUES (4,'D')
INSERT INTO @TestTbl1 (Id,Name) VALUES (5,'E')
INSERT INTO @TestTbl2 (Id,Name) VALUES (6,'F')
INSERT INTO @TestTbl2 (Id,Name) VALUES (7,'G')
INSERT INTO @TestTbl2 (Id,Name) VALUES (8,'H')
INSERT INTO @TestTbl2 (Id,Name) VALUES (9,'I')
INSERT INTO @TestTbl2 (Id,Name) VALUES (10,'J')
INSERT INTO @TestTbl3 (Id,Name) VALUES (11,'K')
INSERT INTO @TestTbl3 (Id,Name) VALUES (12,'L')
INSERT INTO @TestTbl3 (Id,Name) VALUES (13,'M')
INSERT INTO @TestTbl3 (Id,Name) VALUES (14,'N')
INSERT INTO @TestTbl3 (Id,Name) VALUES (15,'O')
IF(@Combobox1='@TestTbl1' AND @Combobox2='@TestTbl2' )
BEGIN
SELECT * FROM @TestTbl1 UNION ALL
SELECT * FROM @TestTbl2
END
ELSE IF(@Combobox1='@TestTbl1' AND @Combobox2='@TestTbl3' )
BEGIN
SELECT * FROM @TestTbl1 UNION ALL
SELECT * FROM @TestTbl3
END
Out Put:
Id Name
1 A
2 B
3 C
4 D
5 E
6 F
7 G
8 H
9 I
10 J