Copying from Query to Table

S

Steve Welman

Hi

I have a form do to data validation on my tables and at one stage I open a
query, diplaying all records in a table based on a policy number which is
input via a parameter to the query.

How do I now copy all records in this query to a table without having to
look the query recordset doing the following

do until qdfrst1.eof()
rst1.addnew
rst1!field1 = qdfrst1!field1
rst1!field2 = qdfrst1!field2
rst1!field3 = qdftst1!field3
rst1!field4 = qdfrst1!field4
...
rst1.update
qdfrst1.movenext
loop

rst1 is the table I want to copy all data to and qdfrst1 is the recordset I
get form running the query

Thanks

Steve
 
S

Stefan Hoffmann

hi Steve,

Steve said:
I have a form do to data validation on my tables and at one stage I open a
query, diplaying all records in a table based on a policy number which is
input via a parameter to the query.
CurrentDb.Execute "INSERT INTO table (fieldlist) SELECT fieldlist FROM
query", dbFailOnError

If you don't like the parameter input box, create a proxy function in a
module:

Public Function ProxyParameter() As Long
'Get the parameter from an input box or somewhere else...
ProxyParameter = 12
End Function

And rewrite your query:
SELECT ID
FROM T1
WHERE ID=ProxyParameter();


mfG
--> stefan <--
 

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