Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
in my QV-App I want to use a button to select some field values. In one field (called LS_BEST_MONAT), a new selection should only be made when there is nothing selected yet.
I have a listbox for that field, it contains year-month values like:
2013-10
2013-11
2013-12
2014-01
...
There are also NULL-Values ( - ) possible.
When there is no selection in this field, pressing the button should select previous month.
This is my code for the button-action 'Select in field [LS_BEST_MONAT]':
=if(GetSelectedCount(LS_BEST_MONAT)=0,
Year(AddMonths(Now(),-1))&'-'&num(Month(AddMonths(Now(),-1)),'00')
)
This works when there were no slections on that field before pressing the button.
But IF there were selections before, after pressing the button the NULL-Values of this field are selected. But in this case, I don't want the previous selection to change, it should stay as it is.
I tried to add else-condition:
=if(GetSelectedCount(LS_BEST_MONAT)=0,
Year(AddMonths(Now(),-1))&'-'&num(Month(AddMonths(Now(),-1)),'00')
,GetFieldSelections( LS_BEST_MONAT)
)
But with this the previous selection simply gets de-selected, so that nothing is selected for this field anymore.
Can somebody help?
Change your Select in Field properties as follows:
Field:
=if(GetSelectedCount(LS_BEST_MONAT)=0, 'LS_BEST_MONAT')
Search String:
=Year(AddMonths(Now(),-1))&'-'&num(Month(AddMonths(Now(),-1)),'00')
If you want the previous selection to be intact and the new ones as additional, try 'Toggle Select' in action.
Edit: Or, for your case try using an additional trigger 'Clear Field' for the same button above the existing one.
Change your Select in Field properties as follows:
Field:
=if(GetSelectedCount(LS_BEST_MONAT)=0, 'LS_BEST_MONAT')
Search String:
=Year(AddMonths(Now(),-1))&'-'&num(Month(AddMonths(Now(),-1)),'00')
This works perfect, thank you!
I'm glad it works for you