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

Announcements
ALERT: QlikView server communication interruptions following Microsoft Windows Domain Controller security updates
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Macro to Check Field Selection

Hello,

I have a field with a single value. I am trying to write a small macro to check and see if the value in that field is selected.

If the value is selected then I don't want anything to happen. If the value is not selected, then I have another macro (which already works) that I want to run.

Can anyone help?

Thanks,

Scott

Labels (1)
5 Replies
Anonymous
Not applicable
Author

Scott,
This will work:


sub MacroName
set f=ActiveDocument.Fields("FieldName")
set s=f.GetSelectedValues
if s.count = 1
' do nothing
else
AnotherMacroName
end if
end sub


Not applicable
Author

Hi Michael,

I inserted the script and added the field name and macro names. I got a message, "Macro Parse Failed. Functionality was Lost."

Suggestions?

Thanks,

Scott

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Scott,

The code is just missing the "then"

if s.count = 1 then

If you use the Check button on the macro editor it will point out the line in error instad of the generic "Macro Parse Failed..." message.

Here's another suggestion for testing the field, which I think is slightly simpler.

sub MacroName2
if ActiveDocument.Evaluate("GetSelectedCount(FieldName)") = 1 then
msgbox "is Selected"
else
msgbox "not Selected"
end if
end sub

Anonymous
Not applicable
Author

See if I misspelled anything. The macro is rather simple, should work.

Anonymous
Not applicable
Author

Sure, I missed "then" - thanks Rob