I am trying to write Dynamic SQL chunks of code in a form class module.
I have a listbox representing YEARS, which is populated with the following values (established by the user, not me).
Listbox Value for YEARS:
-----------------------------------
ALL - value needs to be translated into the current year
1990 - the years 1990 through 2017 as separate values
1991
...
2017
-----------------------------------
I need to take the Listbox value for the YEAR selected by the user via the listbox. I will call the listbox value chosen (year value) as "Variable X". I need to plug the value selected from the listbox into the following SQL statement:
where DateLost <=DateSerial(X -[tblStatesAll].StocksFS,6,30)
Thus, if the User picks ALL, variable X takes on the value 2005. If the user picks 2017, variable X takes on the value 2017.
Would you have any suggestion as to how I rewrite the SQL where clause to incorporate the value for the year selected by the user bearing in mind that ALL represents the current year while the other possible values are just the years
1990 though 2017 ?
I have a listbox representing YEARS, which is populated with the following values (established by the user, not me).
Listbox Value for YEARS:
-----------------------------------
ALL - value needs to be translated into the current year
1990 - the years 1990 through 2017 as separate values
1991
...
2017
-----------------------------------
I need to take the Listbox value for the YEAR selected by the user via the listbox. I will call the listbox value chosen (year value) as "Variable X". I need to plug the value selected from the listbox into the following SQL statement:
where DateLost <=DateSerial(X -[tblStatesAll].StocksFS,6,30)
Thus, if the User picks ALL, variable X takes on the value 2005. If the user picks 2017, variable X takes on the value 2017.
Would you have any suggestion as to how I rewrite the SQL where clause to incorporate the value for the year selected by the user bearing in mind that ALL represents the current year while the other possible values are just the years
1990 though 2017 ?