Select Data Source Based On Outcome Of

C

Chai

I have a form that does not have a record source assigned to it. In the form
I have a combo box, and, after selecting something in the combo box I want
the form to be connected to a table or query. Don't know if this is
possible.

Chai
 
K

KARL DEWEY

Here one way but all sources must have same fields or be able to be displayed
by a set of generic field aliases.

Base the form on a union query that uses a control (combo with 2 columns)
for criteria to determine which portion of the union query will have any
records to output.
SELECT tbl1.SomeName AS T_Name, tbl1.Name_X AS U_Name, tbl1.Name_Y AS V_Name
FROM tbl1
WHERE [Forms]![MyForm]![cbo1] = 1
UNION ALL SELECT tbl2.OtherName AS T_Name, tbl2.Q_Name AS U_Name,
tbl2.N_Name AS V_Name
FROM tbl2
WHERE [Forms]![MyForm]![cbo1] = 2
UNION ALL SELECT tbl3.Other AS T_Name, tbl3.VR_Name AS U_Name, tbl3.CB_Name
AS V_Name
FROM tbl3
WHERE [Forms]![MyForm]![cbo1] = 3;

You will need an AfterUpdate event on combo to refresh the query.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top