Saving querry results in vba

G

Guest

I've used recordset.open <query string>, CurrentProject.connection to run a
query on a table. How can I save the results of such query? I would then
like to show the query results in a listbox and so I'm trying to write the
results to a query which is already a data souce of that listbox.

Many thanks in advance for your comments.
 
A

Allen Browne

You already have the query string you need.
You could therefore display the results in a list box by setting its
RowSource property.

Example:
strSql = "SELECT * FROM Table1;"
Me.[MyListBox].RowSource = strSql

If the list box has RowSource of Query2, and you wanted to alter that query
so that it has the new SQL statement, you could that like this:
CurrentDb.QueryDefs("Query2").SQL = strSql
Me.[MyListbox].Requery
 

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