title: How to display Access query results without having to create temporary query?
body: <p>Note: Please bear with me as I'm relatively new to Access... everything I have learned has been through searching Google as necessary.</p>
  
  <p>So I am creating a form with the sole purpose of searching through a database. In one use-case, the user has the option to select multiple options to filter a search by, for privacy reasons we can say "Blue, Green, Red, Brown". The user can select any combination of those colors, including all or none. In the database table, there is a primary key (in our case, an ItemID). The other columns in the table are the colors above (Blue, Green, Red, Brown). Due to the structuring of this data (note: I cannot change it for multiple reasons), I have to create this SQL query in VBA rather than by using what Access provides. </p>
  
  <p>Here is the code I am using to create and run the query when the "Search" button is pressed:</p>
  
  <pre><code>Set qdf = Nothing
  
  *Logic to create SQL query... variable to hold query is called sqlStr*
  
  Set qdf = CurrentDb.CreateQueryDef("TemporaryQuery", sqlStr)
  DoCmd.OpenQuery qdf.Name
  </code></pre>
  
  <p>As a result of much searching, this is the only way I have found, aside from using ADO, that I can create a SQL query IN VBA and then run it in VBA. The downside to this method, while it works, is that it creates a query, which has to be closed and deleted before the query can be ran again. This is not acceptable for the users that will be using this. </p>
  
  <p>All examples I have found (please bear with me) use ADO, which I have not been able to get to work. I have two databases, one for the queries and forms, and one for the data itself. The database containing the data has it's tables linked to the database with the queries and forms. I'm not sure if ADO can work in that setup, but if it can, I haven't been able to figure it out.</p>
  
  <p>Coming from a Java/Webdev background using Access has been a bit frustrating to me as it just seems to be making things more complicated (in my opinion) that it should be. Can anyone help me get this working correctly? </p>
  
  <p>Thank you for your time... it is greatly appreciated!</p>