Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to set variable FROM table/query name?

Status
Not open for further replies.

marijonas

Technical User
Apr 20, 2004
29
SE
Hi,
I am trying to make a query pic data from diffrent tables depending on the value on a form. I wonder if it is possible and how to make something like this for the FROM:
if form_value=X then choose from table "name_"& form_value, else choose from another table.

Thanx in advance!

 
One simple approach is to use queries.

Define a query for each table that includes the table name:

qrySelectTable1
qrySelectTable2
.
.
etc.

The user chooses which table to query and the code runs the corresponding query. This keeps it simple and the queries can map any fields that have different names to a common set of aliases


 
is it possible to make SQL code to choose the query to use. I have diffrent queries. I want that on the same form different query would be used depending on the user choice in the form.
 
you will need to build the query dynamically depending on the users selections.


Leslie
 
You may dynamically set the RecordSource property of the form depending the user's choice.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top