I can’t figure out which part of this code is written incorrectly.
In my query string, i’m trying to collect a range of records between the values of sFrom and sTo. Basically, I want to make it so that out of all the control numbers that I collect from my database, the only ones that get displayed will be whatever the user inputs for the starting range (sFrom) and the ending range (sTo).
sQuery = "SELECT " & sFields & " FROM " & sTable &
" Where store_id Like 'XXX'" & sFilter &
" Where control_no > sFrom and < sTo " &
order by " & sOrderBy
The best way to debug this is to see what the resultant SQL statement is and work from there.
Yours currently evaluates to something like
sFilterinclusion is very wrong, but it depends in what the exact value is.sFromandsToare included as literals, not evaluated (See tcarvin’s answer)WHEREclause needs to be full and complete. You can’t omit the field to check (See Darrel’s answer)