Saving querry results in vba

  • Thread starter Thread starter Guest
  • Start date Start date
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.
 
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
 
Back
Top