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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Cancel button in MsgBox

Hi Everybody,

I have the following code executed in a macro button:









Sub SelectUA
set s = ActiveDocument.Fields("UA").GetPossibleValues
for i=0 to s.Count-1
m = s.Item(i).Text
ActiveDocument.Fields("UA").Select m
ActiveDocument.GetApplication.Refresh
ActiveDocument.GetApplication.WaitForIdle
tp = ActiveDocument.GetApplication.MsgBox (m,1)
if tp = 1 then
exit for
end if
next
ActiveDocument.Fields("UA").Clear
end sub

the problem is that the MsgBox function allways return a 0 (OK or CANCEL pressed) so the Sub executes until the end of the for loop.

How can I solve this problem ?

Regards,

Thank you.

1 Reply
Not applicable
Author

I usually use the VB Script MsgBox. Try this in place of your MsgBox line:

tp = MsgBox(m, 1)


That should give you a message box with m as the prompt and OK & Cancel buttons. Cancel should return a 2, Ok a 1.