Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi guys!
I have two sheets (sheets1 and sheets2) with a listbox called YEAR with values 2011, 2012, 2013 and 2014.
When sheets1 is open for the fist time, YEAR has to get value 2014, while, when sheets2 is open for the first time YEAR has to get no value.
Then, when sheets1 is open for next time, YEAR has to get last selected value, while, when sheets2 is open for next time, YEAR has to get always no value and go on...
I think the problem is focus on OneAndOnlyOne Property, but i don't know how i can overtake it.
Any suggest ?
Thank you so much for your precious help.
Hi,
Try like this
Create one variable like this in Settings -> Variable Overview
vMaxYear = Max({1} YEAR)
field.Select = ActiveDocument.Variables("vMaxYear ").GetContent.String)
Regards,
Jagan.
Hi,
Not sure if I understand you correctly. You need some selections in list box based on switching of sheets.
If so, then you can use actions/triggers to achieve this.
For 1st scenario (when sheet 1 is opened for the first time):
Assuming sheet 1 is your default sheet on opening the document. You can use Document trigger "OnOpen" of document. Use below action :
Action Type : Selection
Action : Select in field
Here you can give field name as YEAR and Search string as 2014.
For 2nd Scenario (when 2nd sheet is opened) :
Use "Sheet Event Triggers" and give action "OnActivateSheet" :
Action Type : Selection
Action : Clear Other field
Give Field name as YEAR.
This way when you open sheet 2 anytime, it will not have any value in YEAR.
Hope this helps!
Hi,
thank you for your help.
Your suggest was useful for my project.
Just a revision: the action i have used in Sheet Event Triggers was "Clear Field" instead of "Clear Other Fields".
Now sounds good.
But there is another problem: OneAndOnlyOne property of listbox YEAR is setted on "false" and it's ok.
Switching from Sheets2 to Sheets1 it would be necessary that, only in Sheets1, this property was setted on "true" and switching from Sheets1 to Sheets2 on "false".
How can i do ?
Thank you in advance.
Hi,
Try this in macro
set field = ActiveDocument.Fields("YEAR")
field.Select "2014"
set fieldProperties = field.GetProperties
fieldProperties.OneAndOnlyOne = true
field.SetProperties fieldProperties
Regards,
Jagan.
Sounds good.
Thank you !
Just another question.
In this macro, Is it possible to replace the value "2014" with a variable that contains the maximum value of the field "YEAR" of my table "ANAGRAFICA" loaded in the initial script of QlikView?
Thank you in advance.
Stefano
set field = ActiveDocument.Fields("YEAR")
field.Select "2014"
set fieldProperties = field.GetProperties
fieldProperties.OneAndOnlyOne = true
field.SetProperties fieldProperties
Hi,
Try like this
Create one variable like this in Settings -> Variable Overview
vMaxYear = Max({1} YEAR)
field.Select = ActiveDocument.Variables("vMaxYear ").GetContent.String)
Regards,
Jagan.
Hi Jagan, great one !
It works perfectly.
Thank you so much.
If i need more help, may i contact you again ?
Regards,
Stefano.
Hi,
Just post in community, if I am available I will answer otherwise other friends in Community will answer.
Regards,
Jagan.
Right !
Have a nice day.
Regards,
Stefano