I'm having a hard time wrapping my head around QueryDef's--hopefully one of you enlightened individuals can help me out here.
I understand that QueryDef's are just a way to dynamically alter existing saved queries, however I have a few questions...
1) The database application I am developing makes very heavy and frequent use of queries to populate listboxes/comboboxes/textboxes on many of my forms. Is using a QueryDef significantly faster than building and running SQL code from within my code modules?
2) If the answer to question #1 is Yes (and from what I've read, I think it is), then why is it that most of the QueryDef examples I've looked at simply refer to the saved Query, but delete the SQL code from it and replace it with the dynamic code. I.e. If I completely replace the contents of the qdf.SQL property with my new, dynamically created, SQL code, does that defeat the effectiveness of using a QueryDef?
3) From playing around with QueryDef's a little bit, I've figured out that when you make a change to the qdf.SQL property, it is permanent, and affects subsequent use of that query within the code. Is it common practice (and/or advisable) to save a copy of qdf.SQL in order to restore its value when you're done with the current query. Also, does restoring the value to qdf.SQL affect performance? (i.e. does the action of storing a value into qdf.SQL actually cause the query to run in the background, or is it just like assigning any other string to a regular variable or object property?)
I think those are all the questions I have...much appreciated if someone could shed some light for me.
Thanks in advance,
Sam
I understand that QueryDef's are just a way to dynamically alter existing saved queries, however I have a few questions...
1) The database application I am developing makes very heavy and frequent use of queries to populate listboxes/comboboxes/textboxes on many of my forms. Is using a QueryDef significantly faster than building and running SQL code from within my code modules?
2) If the answer to question #1 is Yes (and from what I've read, I think it is), then why is it that most of the QueryDef examples I've looked at simply refer to the saved Query, but delete the SQL code from it and replace it with the dynamic code. I.e. If I completely replace the contents of the qdf.SQL property with my new, dynamically created, SQL code, does that defeat the effectiveness of using a QueryDef?
3) From playing around with QueryDef's a little bit, I've figured out that when you make a change to the qdf.SQL property, it is permanent, and affects subsequent use of that query within the code. Is it common practice (and/or advisable) to save a copy of qdf.SQL in order to restore its value when you're done with the current query. Also, does restoring the value to qdf.SQL affect performance? (i.e. does the action of storing a value into qdf.SQL actually cause the query to run in the background, or is it just like assigning any other string to a regular variable or object property?)
I think those are all the questions I have...much appreciated if someone could shed some light for me.
Thanks in advance,
Sam