Recordset or Query object?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form in which the user selects search criteria and enters values for
that criteria. I can use that to build a select sql string easily enough but
after this I seem to be having a mental blank. Should I use the sql string to
generate a recordset, or should I store it as a query object (overwriting say
a generic query) and execute the query object. Whatever the method I want to
display the result in a datasheet format.
Thanks
Peter
 
Just assign the SQL string you created to the RecordSource property of the
form to get the results you want.

Example:
Dim strSql As String
strSql = "SELECT * FROM Table1 WHERE City = ""Seattle"";"
Forms!Form1.RecordSource = strSql
 
Ok, this is why I was considering going down the save it as a query and
execute the query route. I have never designed a form in a datasheet format
before and dont know how to do it. Also I am anticipating building a
configuration form that will allow the user to select which fields they wish
to display in the output, so I thought if I save it as a query and execute
the query, the default behavior to display the results of a query is in a
datasheet mode (except that I am getting an error about running a select
query when I try this method). I dont know if it is possible to just display
a recordset in a similar manner.
 
No worries. If you would prefer to assign the query, you could create one
for the purpose, and then assign the SQL statement to the QueryDef, e.g.:

CurrentDb.Querydefs("Query1").SQL = strSql
 

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

Back
Top