Page 2 of 2
Re: Search when opening a form.
Posted: Fri Apr 23, 2021 5:00 pm
by kknm
kev1n wrote:Should the form display all records when opened? Then you would this "OR LOCATE( ..." condition in your where clause that I posted earlier.
Initially, it should open - the current month, and by buttons - the current year and return to the current month.
Re: Search when opening a form.
Posted: Fri Apr 23, 2021 5:22 pm
by kev1n
When the form is first opened the Hash Cookie #year_filter#' doesn't exist and hence will not be replaced with its value.
Therefore if your WHERE clause looks like this
Code: Select all
WHERE
(( DATE_FORMAT(p_dat,'%Y-%m') LIKE '#year_filter#'))
you will have to change it to something like this:
Code: Select all
WHERE
(
( LOCATE('#', '#year_filter#') = 1
AND YEAR(your_date_column) = YEAR(CURDATE())
and MONTH(your_date_column) = MONTH(CURDATE())
) OR
(
DATE_FORMAT(p_dat,'%Y-%m') LIKE '#year_filter#'
)
)