SQL to create Table from Query Results

M

mario

Is there an SQL to create a table from Query Results.

I have a query. Then I export the query results to a table by, file->get
external data.

Is there any way I can stream the query results into a table.

I want the table name to be inputed by a user through a dialog box "Please
enter the table name"

Thanks
Mario
 
F

fredg

Is there an SQL to create a table from Query Results.

I have a query. Then I export the query results to a table by, file->get
external data.

Is there any way I can stream the query results into a table.

I want the table name to be inputed by a user through a dialog box "Please
enter the table name"

Thanks
Mario

You could run a make table query, but not if you want the user to
enter the table name.
However, you can use code.

Code the click event, for example, of a Command button:

Dim strTable as String
Dim strSQL as String
strTable = InputBox("Enter the table name.")

strSQL = "SELECT YourTable.FieldName INTO " & strTable _
& " FROM YourTable WHERE YourTable.FieldName Is Not Null;

CurrentDb.execute stSQL, dbFailOnError

Note the space between INTO and the " as well as the space between the
" and FROM.
 
J

John W. Vinson

Is there an SQL to create a table from Query Results.

I have a query. Then I export the query results to a table by, file->get
external data.

File... Get External Data... is a technique to IMPORT records, not to export
them. I'm not sure what you are in fact doing!
Is there any way I can stream the query results into a table.

I want the table name to be inputed by a user through a dialog box "Please
enter the table name"

Thanks
Mario

You can certainly use a make-table query - BUT WHY WOULD YOU WANT TO?

Having multiple unrelated tables all with the same kind of data is *very* bad
design. They clutter and bloat your database; user entered names will be
forgotten within 6 hours; the tables will end up containing duplicate data; at
the *very* best the data in these tables will be redundant with data which is
already in your database.

You may be assuming that you need the data in its own table in order to
generate a report, or a mail merge, or an export. You don't. ALL of these can
be done using a Select query dynamically.
 
M

mario

Thank your for your prompt response.

How can I create tables for all (every) the "named-ranges" in an excel
file. Can you give me an example macro or code which will take the file
location of an excel file and convert all the named ranges in it into an
table. Table names being the same as named ranges.

Thanks
 
M

mario

Thanks for your comments.

I am an GIS Mapping Specialist and not particular on the data structure and
redundancy.

Mario
 

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