Containing Query code entirely in a module?

  • Thread starter Thread starter Steve-O
  • Start date Start date
S

Steve-O

Is there any way to have the code for an Access query
contained completely within a module? I'm trying to both
protect the query and also prevent hundreds of query
objects from existing within the database. The tables I am
trying to query all exist within the Access database. Any
help would be very appreciated! Thank you.
 
You can store the SQL statement as a String variable and then execute it
using various methods (CurrentDb.Execute, CurrentDb.OpenRecordset, etc.).
However, stored queries will run faster, in most cases, than executing a
string SQL statement.
 
Sure!
I do it all the time for exactly those reasons.
PLUS - it is a myth that they run slower.
You will never notice the difference. (I guarantee it.)
=========================================

strCriteria = (some condition that you choose)

strSQL = "SELECT table1.field1, table1.field2 "
strSQL = strSQL & "FROM table1 "
strSQL = strSQL & "WHERE (" & strCriteria & ");"
 
Back
Top