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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating Tables from Queries

Status
Not open for further replies.

hflowers

MIS
Apr 3, 2001
1
US
Is there a method in Microsoft Access that a table can be created from a query other than creating a make table query?
 
Is the following good?
docmd.RonSql "create table ..." John Fill
ivfmd@mail.md
 
No, if you want to do it in code, try this:

"SELECT Field1, Field2, Field3 INTO DestTableName FROM SourceTableOrQueryName;"

Example:

"SELECT OrderNo, OrderDate, CustID INTO tmpCustOrders FROM qryOrders;"

This is what the code would look like:

=====
Private Sub Whatever_Click()
Dim db as Database
Set db = Currentdb
db.Execute "SELECT OrderNo, OrderDate, CustID INTO tmpCustOrders FROM qryOrders;"
db.Close
End Sub
=====

This will create a new table called tmpCustOrders based on the qryOrders Query. You can make this SQL statement as complex as you would like by adding things like WHERE statements, or GROUP BY. Jim Lunde
compugeeks@hotmail.com
Custom Application Development
 
The other option is to create a Make-Table query and save it.

Then in code all you have to do is this:

Docmd.OpenQuery "YourQueryName" Jim Lunde
compugeeks@hotmail.com
Custom Application Development
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top