Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Select & Lock selection in the script

Dear all,

I've developed a QV file with information based on the last 5 years and organised by region/market/...

I would like the year to be selected and locked when I reload the data.

Is there a simple way to have this integrated in the script. I tried the following but (of course) it didn't work.

ActiveDocument.Fields("PERIOD_ID").Select "2010";

ActiveDocument.Fields("PERIOD_ID").Lock;



Thanks for your help

10 Replies
Not applicable
Author

Hi,

Try this.

Access Tools > Edit Module copy and past this code.

Sub SelectAndLock

ActiveDocument.Fields("PERIOD_ID").Select "2010"

ActiveDocument.Fields("PERIOD_ID").Lock

End Sub

Click in Check and OK.

After, Access Settings > Document Properties > Triggers > OnPostReload add action External for Run the Macro.



Not applicable
Author

Hi Fernando

Thanks a lot for the quick reply.

It looks OK. And what if I want to have a multiple selection (e.g 2009 AND 2010).

Should I write select (2010, 2009) ? It seems that it is not recognised as a value list.

Rgds

Not applicable
Author

Hi,

You can trys this.

ActiveDocument.Fields("PERIOD_ID").Select "(2010|2009)"

Not applicable
Author

Yes, it is working. Except when there is a partial reload triggered from a macro.

Thanks again for your reactivity

Not applicable
Author

Hi Fernando,

Is there a simple way to execute the macro (Selectandlock) after the partial reload.

On my file the macro (Selectandlock) is working properly after a full reload but not the partial reload.

And the partial reload is deselecting my field even when locked.

Any idea to solve this problem?

Thanks again

Not applicable
Author

I don´t know.

You try put in OnOpen the Run Marcro.

Not applicable
Author

Yes, I put them on OnOpen and OnPostReload but no result....

Not applicable
Author

Remove from OnPostReload, only OnOpen.

Not applicable
Author

Hi Tony,

I don't want to waste your time. But just to inform you that even with OnOpen I have the same result, i.e. selection is lost and I'm not able to select Years anymore, I have to go for a full reload.

Rgds