Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I want to be able to view the fields and values selected within a bookmark and display this in a textbox on a sheet so that the user is able to see exactly what the bookmark contains. How do I do this?
I think I may have found the answer in QlikCommunity.....
I have downloaded an example that on clicking each button, once the bookmark is saved, the current selections are saved to a variable. I can then display the variable contents in a textbox!!!
YIPPEEE this works!!!
There is an object type called "Current Selections Box" which shows all the selected fields and it's values. Is this what you are looking for?
Not fully...This is what I am doing....
I am comparing to sets of data to each other. The user will make their selections, then click on Button1 which saves the selections in Bookmark1. They then change their selections and click on Button2 which saves the selections in Bookmark2. I then use Set Analysis in the views to compare Bookmark1 to Bookmark2.
The problem is that it is not easy for the user to see/remember what they selected in either Bookmark and I wanted to show them this in a textbox at the top of the sheet.
I think I may have found the answer in QlikCommunity.....
I have downloaded an example that on clicking each button, once the bookmark is saved, the current selections are saved to a variable. I can then display the variable contents in a textbox!!!
YIPPEEE this works!!!
Hi,
This topic is also interesting for me, can you (renem) please post the link where you have found the solution, or post the example here, that would be great. Thank you!
Regards,
Herbert
I found this at http://community.qlik.com/media/p/63290.aspx
I have run into problems when trying to use this with QV Server as Set Analysis only uses Document Bookmarks and not User Bookmarks. Does anyone know how to do it?
Hi,
I am having the same problem, did you find a solution for that?
Best regards
Stefan
Hi
Yes, I did. I had to write some VB script to do this. Instead of creating a Document Bookmark, I create a User Bookmark and build up the set analysis string by going through each of the selected fields in Current Selections and build up the values using GetSelectedValues. Tricky, but it works
Sub AdHoc_Group1
ActiveDocument.RemoveDocBookmark "BM1"
ActiveDocument.CreateDocBookmark false, "BM1"
ActiveDocument.RecallDocBookmark "BM1"
BM1Sel = ""
set x = ActiveDocument.GetCurrentSelections
s = x.Selections
v = x.VarId
for i = lbound(s) to ubound(s)
BM1Sel = BM1Sel & v(i)&" = "&s(i) & chr(10) & chr(10)
next
ActiveDocument.GetSheetObject("TX2757").SetText BM1Sel
set tx = ActiveDocument.GetSheetObject("TX2757")
set txprop = tx.GetProperties
txprop.Layout.Frame.helptext.v = BM1Sel
tx.SetProperties txprop
end sub
This is the code for Macro.. It is working, already using it.
Yes, this is great...but you can't use it with QV Server as a thin client user can't create document bookmarks.
I used this code originally and displayed the contents of the variable in the text box:
'Create and set Document Bookmark
ActiveDocument.RemoveDocBookmark "BMStudyPopulationDocBook"
ActiveDocument.CreateDocBookmark false, "BMStudyPopulationDocBook" 'Syntax for document bookmark different from user bookmark
ActiveDocument.RecallDocBookmark "BMStudyPopulationDocBook"
'Set variable to current selections to show in text box
set v1 = ActiveDocument.Variables("vStudyPopulationSelectionsDocBook")
v1.SetContent ActiveDocument.Evaluate("getcurrentselections()"),true
I have since changed it to the following:
'Create and set User Bookmark
ActiveDocument.RemoveUserBookmark "BMStudyPopulation"
' ActiveDocument.CreateDocBookmark false, "BMStudyPopulation" 'Syntax for document bookmark different from user bookmark
ActiveDocument.CreateUserBookmark "BMStudyPopulation"
ActiveDocument.RecallUserBookmark "BMStudyPopulation"
'Set variable to current selections to show in text box
set v1 = ActiveDocument.Variables("vStudyPopulationSelections")
v1.SetContent ActiveDocument.Evaluate("getcurrentselections()"),true
'Create the Set Analysis variable made up of current selections as user bookmarks don't work with set analysis in QVServer
set v2 = ActiveDocument.Variables("vSetAStudyPopulation")
v2.SetContent "",true 'clear value in variable
set str = v2.GetContent
str.string = "{1<" 'add first part of set analysis. Use 1 to clear all selections before setting value
set x = ActiveDocument.GetCurrentSelections
s = x.Selections
v = x.VarId
tAddComma2 = 0 'used to add comma before each field selected and stop comma from being added at the end of the list
for i=lbound(s) to ubound(s) 'step thru each selection
if tAddComma2 = 1 then
str.string = str.string & ","
end if
set myselections = ActiveDocument.Fields(v(i)).GetSelectedValues(10000) 'put the number after GetSelectedValues as the default array size is 100
str.string = str.string & v(i) & "={"
tAddComma1 = 0 'used to add comma before each value selected and stop comma from being added at the end of the list
for y=0 to myselections.count-1 'step thru each value selected and add to list
if tAddComma1 = 1 then
str.string = str.string & ","
end if
str.string = str.string & """" & myselections.item(y).text & """" 'add each value to list
tAddComma1 = 1
next
str.string = str.string & "}"
tAddComma2 = 1
next
str.string = str.string & ">}" 'close set analysis string
v2.SetContent str.string,true 'set set analysis value