Instead of using Nested If statements, I was wondering if there is a way to void out parts of a string query if cell value is left blank.
Cell structure is as below:
Cell values from these parameters will get passed into vba code that queries a database. Ideally I don't want to create an individual query for each selection type - and I have it dynamically querying from location already. I want to extend the query to include possible combinations of start, end, value >, value <, while also making it so that if cell value is left blank, then ignore that parameter. So say
SELECT *
from database
WHERE location = 'cell_loc'
AND Value >= 'cell_value'
AND Value <= 'cell_value'
AND Start >= 'cell_date'
AND End <= 'cell_date'
Now imagine that Start is left blank, meaning I want to query from first data point in the database:
I could write a nested if to handle this, but was wondering if there was a way to void out a query parameter so that I could just have a single query fed to database with different parameters changing based off cell data?
Something along the lines of:
SELECT *
from database
WHERE location = 'cell_loc'
AND Value >= 'cell_value'
AND Value <= 'cell_value'
AND Start >= 'cell_date' --> this would be voided out
AND End <= 'cell_date'