<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Macro not running after function call in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Macro-not-running-after-function-call/m-p/585473#M217257</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please check setting&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Vikas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 14 Feb 2014 04:37:51 GMT</pubDate>
    <dc:creator>vikasmahajan</dc:creator>
    <dc:date>2014-02-14T04:37:51Z</dc:date>
    <item>
      <title>Macro not running after function call</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-not-running-after-function-call/m-p/585472#M217256</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am trying to run the following code -&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Function applySel(selDim,selVal)&lt;/P&gt;&lt;P&gt;&amp;nbsp; ActiveDocument.Fields(selDim).Clear&lt;/P&gt;&lt;P&gt;&amp;nbsp; msgbox("cleared")&lt;/P&gt;&lt;P&gt;&amp;nbsp; ActiveDocument.Fields(selDim).Select selVal&lt;/P&gt;&lt;P&gt;&amp;nbsp; msgbox("selected")&lt;/P&gt;&lt;P&gt;end Function&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;sub Apple&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;set s1 = applySel("fruits","apple")&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;msgbox("apple selected")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;end sub&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;The msgbox is not getting executed, though I see that the selection was successfully made. Please help.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Feb 2014 02:51:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-not-running-after-function-call/m-p/585472#M217256</guid>
      <dc:creator />
      <dc:date>2014-02-14T02:51:13Z</dc:date>
    </item>
    <item>
      <title>Re: Macro not running after function call</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-not-running-after-function-call/m-p/585473#M217257</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please check setting&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Vikas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Feb 2014 04:37:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-not-running-after-function-call/m-p/585473#M217257</guid>
      <dc:creator>vikasmahajan</dc:creator>
      <dc:date>2014-02-14T04:37:51Z</dc:date>
    </item>
    <item>
      <title>Re: Macro not running after function call</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-not-running-after-function-call/m-p/585474#M217258</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I assume you mean the "&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;msgbox("apple selected")&lt;/SPAN&gt;" is not getting executed. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A function should return something. At a minimum, the end of your applySel function should do something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;applySel = ""&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;You function call "set s1=..." is expecting an object return, that's incorrect based on your Function applySel coding. I expect your macro is terminating with an "object expected" error. Since you are not returing an object your call should be:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;s1 = applySel("fruits","apple")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;without the set. Since you are not returning anything, you may want to consider making applySel a SUB instead. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;-Rob&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;A class="jive-link-external-small" href="http://robwunderlich.com"&gt;http://robwunderlich.com&lt;/A&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Feb 2014 04:49:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-not-running-after-function-call/m-p/585474#M217258</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2014-02-14T04:49:07Z</dc:date>
    </item>
    <item>
      <title>Re: Macro not running after function call</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-not-running-after-function-call/m-p/585475#M217259</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Rob. Removing 'set' worked - the details were informative.&lt;/P&gt;&lt;P&gt;And yes, I was talking about the "apples selected" message (will edit the other msgbox out).&lt;/P&gt;&lt;P&gt;I have a few other questions -&lt;/P&gt;&lt;P&gt;1. How do I call a sub in another sub?&lt;/P&gt;&lt;P&gt;2. Using&lt;/P&gt;&lt;P&gt;applySel("fruits","apple") &lt;/P&gt;&lt;P&gt;instead of &lt;/P&gt;&lt;P&gt;s1 = &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;applySel("fruits","apple")&lt;/SPAN&gt; throws up error - 'Cannot use parentheses when calling a Sub'&lt;/P&gt;&lt;P&gt;whereas when I call another function &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;clearSel() it works fine without assigning it to any variable.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Function clearSel()&lt;/P&gt;&lt;P&gt;&amp;nbsp; ActiveDocument.ClearAll true&lt;/P&gt;&lt;P&gt;end Function&lt;/P&gt;&lt;P&gt;sub&lt;/P&gt;&lt;P&gt;clearSel()&lt;/P&gt;&lt;P&gt;end sub&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Feb 2014 07:07:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-not-running-after-function-call/m-p/585475#M217259</guid>
      <dc:creator />
      <dc:date>2014-02-14T07:07:01Z</dc:date>
    </item>
    <item>
      <title>Re: Macro not running after function call</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-not-running-after-function-call/m-p/585476#M217260</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;clearSel() is not receiving any arguments so you dont need to assign any variable, but &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;applySel is having parameters so you have assign a value to applySel variable.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;Syntax of function:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;[Public [Default] | Private] Function name [(arglist)]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; [statements]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; [name = expression]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; [Exit Function] &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; [statements]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; [name = expression]&lt;/P&gt;&lt;P&gt;End Function&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;Function ShowSum(value1, value2)&lt;/P&gt;&lt;P&gt;&amp;nbsp; Dim sum&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; ' Determine and display the sum.&lt;/P&gt;&lt;P&gt;&amp;nbsp; sum = value1 + value2&lt;/P&gt;&lt;P&gt;&amp;nbsp; MsgBox "The sum is: " &amp;amp; sum&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; ' Set the function's return value.&lt;/P&gt;&lt;P&gt;&amp;nbsp; ShowSum = sum&lt;/P&gt;&lt;P&gt;End Function&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Calling Function:&lt;/P&gt;&lt;P&gt;----------------------&lt;/P&gt;&lt;P&gt;Dim retValue&lt;/P&gt;&lt;P&gt;' Call the function with and without the Call keyword.&lt;/P&gt;&lt;P&gt;Call ShowSum(3, 4)&lt;/P&gt;&lt;P&gt;ShowSum 5, 6&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;' Omitting the Call keyword enables access&lt;/P&gt;&lt;P&gt;' to the function's return value.&lt;/P&gt;&lt;P&gt;retValue = ShowSum(7, &lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt;&lt;/P&gt;&lt;P&gt;MsgBox "The function returned: " &amp;amp; retValue&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Jagan.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Feb 2014 07:25:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-not-running-after-function-call/m-p/585476#M217260</guid>
      <dc:creator>jagan</dc:creator>
      <dc:date>2014-02-14T07:25:08Z</dc:date>
    </item>
  </channel>
</rss>

