Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Using sheet trigger to set default selections in multi box

Hello,

I need to set default selections in a multi box when a user first clicks a tab.  The first option that came to mind is using a sheet trigger (OnActivateSheet) in order to set selections on multiple fields.  When I attempt this there are some selections that are set properly and others that are not.  I have tried both action type 'Select in Field' as well as invoking a macro to do the work, both with the same results.  I am using QV11.  Are there known issues with this approach?

Here is an example of the macro:

Sub initselect

          Set var1 = ActiveDocument.Variables("v1")

          Set var2 = ActiveDocument.Variables("v2")

          x = var1.GetContent.String

          y = var2.GetContent.String

          ActiveDocument.GetField("Field1").Select ActiveDocument.Evaluate(x + y)

  ActiveDocument.GetField("Field2").Select ActiveDocument.Evaluate("'XYZ'")

          ActiveDocument.GetField("Field3").Select ActiveDocument.Evaluate("'ABC'")

End Sub

When this executes only Field2 and Field3 have selections set.  If I comment out the line where Field2 is set, Field1 and Field3 will have selections set.  Not certain what the cause of this inconsistent behavior could be.

Any input would be appreciated.

1 Solution

Accepted Solutions
isaiah82
Creator III
Creator III

I would recommend you use the built-in trigger for making the field selections instead of the macro, but that's just my two cents.

Without seeing your document, I'm guessing that the 2nd or 3rd selection is incompatible with the first (in your data model.)  Try the selections in the UI manually in the same order they are in your macro and see if you don't get the same result.  If you do, please post a sample.  -Isaiah

View solution in original post

3 Replies
isaiah82
Creator III
Creator III

I would recommend you use the built-in trigger for making the field selections instead of the macro, but that's just my two cents.

Without seeing your document, I'm guessing that the 2nd or 3rd selection is incompatible with the first (in your data model.)  Try the selections in the UI manually in the same order they are in your macro and see if you don't get the same result.  If you do, please post a sample.  -Isaiah

Anonymous
Not applicable
Author

Is it possible to make the same combination of selections manually?  If not, the macro/actions will not help.

Not applicable
Author

Yes, I would prefer to use the built-in trigger as well.  The issue was with the data available per the data model.  So... the selections will not set if there are no instances of the value in the filtered results. 

Thanks for your feedback!