Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Macro to return selected values in list box

Greetings,

I have a listbox with user selections. I would like to be able to return a string of the selected values from the listbox.  GetSelectedValues returns something other than a string.  Does anyone know if this is possible to do?

Thanks,

Frank

1 Solution

Accepted Solutions
Not applicable
Author

Thanks whiteline. I solved my problem. I created a hidden sheet. On the hidden sheet I put a text object. The text is =CHR(40)&CHR(39)&getfieldselections(AccountNo,CHR(39)&','&CHR(13)&CHR(39),2000)&CHR(39)&CHR(41)In the macro I process the string like this:

Set TX = ActiveDocument.getSheetObject("TX01")

Then i run a SQL Statement through an ADODB connection

ADODBConn.Execute(Update [databasename].[dbo],[tablename] set [fieldname] = 1 where [AccountNo] in "&TX.GetText)


View solution in original post

5 Replies
whiteline
Master II
Master II

Hi.

You can easily get all possible values using =Concat(distinct YourField, ', ')

Not applicable
Author

Thanks for the rapod reply. I really don't need possible values unless those are the values selected by the user. The SQL that I want to use would be like "update Accounts Set active = 1 where AccountNumber in (this is where the selcted listbox values go)"

whiteline
Master II
Master II

You can check if there are some selection with another function.

Not applicable
Author

Thanks whiteline. I solved my problem. I created a hidden sheet. On the hidden sheet I put a text object. The text is =CHR(40)&CHR(39)&getfieldselections(AccountNo,CHR(39)&','&CHR(13)&CHR(39),2000)&CHR(39)&CHR(41)In the macro I process the string like this:

Set TX = ActiveDocument.getSheetObject("TX01")

Then i run a SQL Statement through an ADODB connection

ADODBConn.Execute(Update [databasename].[dbo],[tablename] set [fieldname] = 1 where [AccountNo] in "&TX.GetText)


whiteline
Master II
Master II

So its limited with the 2000.

I meant that you could use getselectedcount() to check if there is any selection and then use concat() to build the same list.