Insert Query output into a table

P

Pentlavalli

Hello all,

I am writing a form programming where I have to fill table T3 from two tables
T1 and T2 upon a button click.

I have a complecatd query Q1 on T1 & T2 whose output should be inserted into
T3.

Would anybody help me how to achieve this in form programming.

If I write query as SELECT ....... FROM T1, T2 ......etc.... and double click
on it, I am getting the list of rows I wanted.

If I write query as INSERT INTO T3 SELECT ....... FROM T1, T2 ......etc....
and double click on that, all these rows are inserted into T3.

But the question now is, how to execute this with FORM PROGRAMMING.....

Any help is appriciated ....

Thanks
Sri
 
B

bhicks11 via AccessMonster.com

You may need to give more details. However, if you just want to run the
query from, say a button on a form, you put DoCmd.OpenQuery "QueryName" in
the OnClick event.

Bonnie
http://www.dataplus-svc.com
 
P

Pentlavalli

I use the following command where "distRows" is the name of my query with
INSERT statement and "LogReportOverview" is my destination table.

But no rows are filled into my destination table.

filName = CurrentProject.Path & "\" & CurrentProject.Name

DoCmd.TransferDatabase acImport, "Microsoft Access", filName, acQuery,
"distRows", "LogReportOverview", False

You may need to give more details. However, if you just want to run the
query from, say a button on a form, you put DoCmd.OpenQuery "QueryName" in
the OnClick event.

Bonnie
http://www.dataplus-svc.com
Hello all,
[quoted text clipped - 18 lines]
Thanks
Sri
 
B

bhicks11 via AccessMonster.com

Have you tested the query outside the form? Perhaps there is a problem with
your update query.

Bonnie
http://www.dataplus-svc.com
Hello Bonnie,

If I use DoCmd.OpenQuery, I see the list of rows resulting my query. What I
want is to insert them into a table.

Thanks.
You may need to give more details. However, if you just want to run the
query from, say a button on a form, you put DoCmd.OpenQuery "QueryName" in
[quoted text clipped - 8 lines]
 
P

Pentlavalli via AccessMonster.com

Hello all,

At last I could find the solution myself.

Public Sub testInsert()

Dim qd As QueryDef

Dim db As Database

Set db = CurrentDb

Set qd = db.QueryDefs("InsertMe")

qd.Execute

End Sub


Have you tested the query outside the form? Perhaps there is a problem with
your update query.

Bonnie
http://www.dataplus-svc.com
Hello Bonnie,
[quoted text clipped - 8 lines]
 

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