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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Checking return for Select in macro

I want to provide a message if the Select in the macro fails. With the code below, I'm getting the error Expected 'Then', with "District of Columbia" = false then highlighted. Anyone have a suggestion? Thanks.

if ActiveDocument.Fields("STATE_NAME"). Select "District of Columbia" = false then msgbox("Data does not exist for the selected Reporting State.")

end if





Labels (1)
1 Solution

Accepted Solutions
rwunderlich
MVP
MVP

To get a return value from Select, you must use the function argument form -- that is, enclose the argument in parens.

if ActiveDocument.Fields("STATE_NAME").Select("District of Columbia") = false then msgbox("Data does not exist for the selected Reporting State.")


Also. if using the single-line syntax If, don't include an End If.

-Rob

View solution in original post

3 Replies
rwunderlich
MVP
MVP

To get a return value from Select, you must use the function argument form -- that is, enclose the argument in parens.

if ActiveDocument.Fields("STATE_NAME").Select("District of Columbia") = false then msgbox("Data does not exist for the selected Reporting State.")


Also. if using the single-line syntax If, don't include an End If.

-Rob

Not applicable
Author

Sorry, that shouldn't have posted.





Not applicable
Author

Rob, that is exactly what I needed. Thanks for your help. Laurie