Hi all,
I am using a controls placed on my main form to build up search criteria to populate my subform.
The basic selections create a dynamic WHERE for my sql statement, dependent on selections made.
Now what I want to see critiqued is my final lines implementing the code which are:
The subfrmSearch can take on 2 different stylings for the output hence why I am setting a specific sourobject at run time. This is purely for aesthetics and the fact I am using a tab control on my main form to differentiate between two types of searches that can be performed.
Anyway, more importantly the second line of code where I set the subform recordsource to be a sql string of:
strwhere is the dynamic string for the where clause. But have I used the most optimal method here for returning results?
I have read a couple of responses to similar questions with the "always make sure you only return what is needed". My code follows this due to the WHERE clause returning only the ROWS which are required, I have filtered out any un-needed columns in my compiled query qrySearch_onCas e and for me that is a nicer format to be adding in any extra columns I may require from my original table.
Once again though is this the best way? Or should I just base my subform record source on the compiled query and filter THE FORM, not run a sql statement?
I am using a controls placed on my main form to build up search criteria to populate my subform.
The basic selections create a dynamic WHERE for my sql statement, dependent on selections made.
Now what I want to see critiqued is my final lines implementing the code which are:
Code:
Me.subfrmSearch.SourceObject = "subfrmSearch_OnCase"
Me.subfrmSearch.Form.RecordSource = "Select * FROM qrySearch_OnCase WHERE " & strwhere
Anyway, more importantly the second line of code where I set the subform recordsource to be a sql string of:
Code:
Select * FROM qrySearch_OnCase WHERE " & strwhere
I have read a couple of responses to similar questions with the "always make sure you only return what is needed". My code follows this due to the WHERE clause returning only the ROWS which are required, I have filtered out any un-needed columns in my compiled query qrySearch_onCas e and for me that is a nicer format to be adding in any extra columns I may require from my original table.
Once again though is this the best way? Or should I just base my subform record source on the compiled query and filter THE FORM, not run a sql statement?
Comment