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!

Union Query to Update to Table

Status
Not open for further replies.

AGGGG

Programmer
Oct 8, 2003
20
GB
Hi,

I have created a union query (works ok), and trying to update the query results to a table. I cannot use the 'make table' as I want to update the table at regular intervals.

I think (hope) that I am missing the obvious solution !

Thanks in advance, Andy

 
A union query is not updateable. When you use the union query in another query, it will render the other query non-updateable. There are possibly ways to get around this with the most common being creating a table to store the union query records.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Hi,
I have already created a table, but not sure how to create the script to update the table.
Cheers, Andy


 
If I understand correctly, you would delete all records from the table and then create an append query based on the union query.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Or, perhaps, execute a make table query based on the union query.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PH,
I'm not sure how helpful a make table query would be since it doesn't get created with a primary key. I had assumed the results would be used in an update query with another table but I could easily be confused ;-)

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
OOps, I surely misunderstood the issue.
Any chance that Andyfaescotland restates the real issue ?
 

INSERT INTO TheTable(FieldsList) SELECT FieldsList FROM qryMyUnionQuery

FieldsList has to use the same number of fields in both cases. The SELECT FieldList can use Alias names if the source field names are different than the destination field names.

If the fields in both tables are identical, you can just use:
INSERT INTO TheTable SELECT * FROM qryMyUnionQuery
 
Hi,

Apologies for not replying sooner ;o)
Used the
INSERT INTO TheTable SELECT * FROM qryMyUnionQuery
and it is working

Thanks for all ur help,
Cheers,
Andy
 
Looks like I answered in haste !

I need the script below to an update query ?

Cheers, Andy

INSERT INTO tblPlanner_Airdrie
SELECT *
FROM QPlanner1;
 
If I understand correctly, you now need to create an additional query that uses tblPlanner_Airdrie to update.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Hi Duane,

Thanks for the help.

I have created a select query (QPlanner1) that is based a union query. The select query is used to pass parameters from a form.

I require a query that will update QPlanner1 to tblPlanner_Airdrie

I am not a programmer, so apologies in advance for my method.

Cheers,
Andy



 
I am not a programmer
What we see:
Andyfaescotland (Programmer)
So, the truth is elsewhere ?
 
I think you need to start from the beginning and provide more information.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top