Solved

How to take results from an query and put them into a table

Posted on 2015-01-08
10
138 Views
Last Modified: 2015-01-08
Hello,

I ran a query and would like the results of the query to into the table....I need to do this each time I run the query
0
Comment
Question by:Jass Saini
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 40538142
The syntax for that would be something like

INSERT INTO TableB (Field1, Field2, Field3)
SELECT Field1, Field2, Field3
FROM TableA
WHERE Field1 = 2

All you really need to do is add the INSERT line, with the name of the table you want to append to, and the fields you want to place the output of your query in.  Making sure that the field types in TableB and the query must match (but the field names do not have to).
0
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40538144
Do you mean a new table or an existing table?

Go to Design Mode and

- If the former, click on "Make Table".
- If the latter, click on "Append".

Enter the table name.
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 40538153
I'll assume you are running a SELECT query
in design view of your query, change your SELECT query into an APPEND query
select the Destination table from the dropdown in the Append window

select the destination fields in the

Append to: row of the query
0
 

Author Comment

by:Jass Saini
ID: 40538193
Here is my query

TRANSFORM Sum(Final_Table.[Total Initial]) AS [SumOfTotal Initial]
SELECT Final_Table.[Org Name], Final_Table.[CostCen], Final_Table.Fund, Final_Table.PEC, Final_Table.BC1Chng1, Final_Table.BC2Chng1
FROM Final_Table
GROUP BY Final_Table.[Org Name], Final_Table.[CostCen], Final_Table.Fund, Final_Table.PEC, Final_Table.BC1Chng1, Final_Table.BC2Chng1
PIVOT Final_Table.[Line Item];

Open in new window

0
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40538206
Do the Make Table or Append in a different query, based on your above query.
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Author Comment

by:Jass Saini
ID: 40538210
Rey,

I tried that ...I have 900 records and this is a crosstab and when I change to an append query...it wanted to append 7124 records.  That not what I want.
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 40538211
create a new query (DO NOT select any table), go to SQL view

copy the below sql and paste to the new query
select A.* Into NewTable
From
(
TRANSFORM Sum(Final_Table.[Total Initial]) AS [SumOfTotal Initial]
SELECT Final_Table.[Org Name], Final_Table.[CostCen], Final_Table.Fund, Final_Table.PEC, Final_Table.BC1Chng1, Final_Table.BC2Chng1
FROM Final_Table
GROUP BY Final_Table.[Org Name], Final_Table.[CostCen], Final_Table.Fund, Final_Table.PEC, Final_Table.BC1Chng1, Final_Table.BC2Chng1
PIVOT Final_Table.[Line Item]
) As A

Open in new window

0
 

Author Comment

by:Jass Saini
ID: 40538231
I am getting a Syntax error in From clause
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 40538245
if you have saved your crosstab quey, you can use

'create new table

SELECT crosstabquery.* INTO NewTable
FROM  crosstabquery

or
'append to your table
 
INSERT INTO NewTable
SELECT crosstabquery.*
FROM crosstabquery

change  "crosstabquery" with the name of the crosstab query
0
 

Author Closing Comment

by:Jass Saini
ID: 40538248
Thanks Rey....I will try that!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Trying to open a report with a filter 2 17
Sending Attachment via CDO 3 22
Help with SQl and UNION 3 19
Query 14 19
In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now