Solved

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

Posted on 2015-01-08
10
150 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 48

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 120

Expert Comment

by:Rey Obrero (Capricorn1)
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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 

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
 

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 120

Expert Comment

by:Rey Obrero (Capricorn1)
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 120

Accepted Solution

by:
Rey Obrero (Capricorn1) 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Access Runtime Error '3070' 5 52
Access 2007 Compact and Repair Back-End Database 9 53
Compress Newid value ms sql Mssql 4 48
SUBFORM on ACCESS 2013 8 37
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

710 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