Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

Not applicable

Using an Input box to search a List Box

Hello

I want to allow the users to enter some search strings into an Input Box, then click a button to find and select items in a list box that match their search values, as if they had just clicked the search button on the list box caption bar, entered their search and pressed enter to select the matching items.

How can I do this? Do I need to write a macro?

Thanks for your help.

James

One other question: when you post up replies I see sometimes you refer to attachments, but I can't see where you access them from, can anyone tell me?

1 Solution

Accepted Solutions
mov
Esteemed Contributor III

Using an Input box to search a List Box

James,

1. It easy to implement with a macro:


sub SelectVar
ActiveDocument.Fields("Field").Clear
set vSel = ActiveDocument.Variables("vSelect")
ActiveDocument.Fields("Field").Select vSel.GetContent.String
end sub

Notice that I'm using here variable vSelect. As in a regular search you can use * and ?.

2. To send attachment, use "Reply" on the right, not the "Quick Reply", and see tab "Options"

9 Replies
mov
Esteemed Contributor III

Using an Input box to search a List Box

James,

1. It easy to implement with a macro:


sub SelectVar
ActiveDocument.Fields("Field").Clear
set vSel = ActiveDocument.Variables("vSelect")
ActiveDocument.Fields("Field").Select vSel.GetContent.String
end sub

Notice that I'm using here variable vSelect. As in a regular search you can use * and ?.

2. To send attachment, use "Reply" on the right, not the "Quick Reply", and see tab "Options"

Not applicable

Using an Input box to search a List Box

Yes, that can be accomplished using a macro. I think there should be a thread on the first page about filtering based on a variable. I didn't follow the thread, but that may be a good thing to check out.

If you open the APIGuide.qvw that should have been installed with QlikView, you can find quite a bit of information on the object model.

For your purposes, you'd need to access the variable and then set a Selection based on the entered value.

As for attachments, if another user has attached a file, there will be a link below their name. To add an attachment to your post, use the Add/Update Attachments button on the Options tab when replying to or composing a new message.

Not applicable

Using an Input box to search a List Box

Hi,

great Macro. It is possible to do this with not only one search string? I want to insert a lot of ID's in the input field and want to select all matching ID's in the other field with a macro.

Thanks,

jup

blaise
Contributor III

Using an Input box to search a List Box

this can also be done, but it require a bit more code Smiley Happy

First, make sure that the values in the inputbox is comma separated. Then write a macro that split() the string and then use toggleselect() to select each of the values in the array to your object. Split() is a built in VBSCript function (use google) and toggleselect is a Qlikview api function (use apiguide.qvw).

EDIT:

Im kind today so I'll share the code;



sub MultipleSelect
set doc = ActiveDocument
set obj = doc.Fields("TransLineID")
set var = doc.Variables("vSelectArray")
varArray = var.GetContent.String
varValue = split(varArray,",")
obj.Clear
for i=lbound(varValue) to ubound(varValue)
obj.ToggleSelect varValue(i)
next
end sub


Not applicable

Using an Input box to search a List Box

Thanks man!

This is something that I have been searching for a while! I had a problem at first but then realized that I needed to trim the varValue. I also wanted to include the wildcards in the search.

My redefined code looks like this:

for i=lbound(varValue) to ubound(varValue)
SearchString="*"& trim(varValue(i)) & "*"
ActiveDocument.Fields("InstallationName").ToggleSelect SearchString
next

Not applicable

Using an Input box to search a List Box

Thanks again. It works great!

But I have another question now:

I switched from using comma seperated IDs to line breaked ID's with this line:

varValue = split(varArray,CHR(10))

Now if I copy the IDs with a line break, for example:

320935511
606338689
-1211816315
-681787372
76711
76714
76778
1747704

the sort of the selected fields after running the macro isn't the same I posted in the input field. I haven't checked any sort option for this field.
1. Is it possible to sort the selected ID's like the sort of the ID's from the input field?

2. Is it possible to use input fields with multiple lines? (QlikView 8.5)

Thanks jup

Not applicable

Using an Input box to search a List Box

Thanks again. It works great!

But I have another question now:

I switched from using comma seperated IDs to line breaked ID's with this line:

varValue = split(varArray,CHR(10))

Now if I copy the IDs with a line break, for example:

320935511
606338689
-1211816315
-681787372
76711
76714
76778
1747704

the sort of the selected fields after running the macro isn't the same I posted in the input field. I haven't checked any sort option for this field.
1. Is it possible to sort the selected ID's like the sort of the ID's from the input field?

2. Is it possible to use input fields with multiple lines? (QlikView 8.5)

Thanks jup

prabhu0505
Valued Contributor

Using an Input box to search a List Box

very useful post

Not applicable

Using an Input box to search a List Box

Hi blaise,

could you help me with my question below?

Thanks,

jup

Community Browser