Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How To Exclude Values Using A Macro

I need to use a macro to conditionally exclude values in a list box.

I can successfully select and deselect items using ToggleSelect, but this method does not allow me to explicitly exlude values.  Is a method available to explicitly exclude values from a list box?

Here's a sample code fragment:

    'Get the selected values from the target field.
    Set qvValues = qvField2.GetSelectedValues(pintLimit, True)
   
    'Check whether any values have been explicitly selected in the target field.
    If qvValues.Count = 0 Then
        'Get the array of possible values from the target field.
        Set qvValues = qvField2.GetPossibleValues(, True)

        'Loop through the values of the target field.
        For intCount = 0 To qvValues.Count - 1
            'Exclude the current item in the target field.  (This method leaves the values in a "possible" selection state and does not exclude them.)
            qvField2.ToggleSelect qvValues(intCount).Text, True, 1
        Next
    End If

Does anyone know how to solve this particular problem?

2 Replies
Anonymous
Not applicable
Author

I have attempted to implement the SelectAndValues method in my code, but I'm getting an error on the last line of code.  There is no description for the error, but the error number is -2147467259.  I've tried everything I know how to do with VB script and I am still unable to eliminate this error.  Is anyone successfully using the SelectAndValues method in QV 11 SR2?
    'Set reference to the target field that is displayed in the list box.
    Set qvTargField2 = ActiveDocument.Fields(pstrTargetField2, pstrTargetState)
   
    'Create an empty array of items to be selected.
    Set qvANDSelect = qvTargField2.GetNoValues()
   
    'And select value.
    qvANDSelect.Add
    qvANDSelect(0).Text = "Active 1"
    qvANDSelect(0).IsNumeric = False
   
    'Create an empty array of items to be excluded.
    Set qvNOTSelect = qvTargField2.GetNoValues()
   
    'Not select value.
    qvNOTSelect.Add
    qvNOTSelect(0).Text = "Active 555"
    qvNOTSelect(0).IsNumeric = False
   
    'Exclude the current item in the second target field.
    qvTargField2.SelectAndValues qvANDSelect, qvNOTSelect, True
Not applicable
Author

Hi,

I am trying to make a a selection from a list box which has an expression in it.

I generally use the below syntax to select values from list box:-

listbox3=Array("<value>")

Set Qv = CreateObject("QlikTech.QlikView")

Set QvDoc = Qv.OpenDoc("<QV_File_location>")

QvDoc.GetSheetObject("<objectID")

Set fz = QvDoc.Fields("objectname")

for each v in listbox3

  fz.ToggleSelect v

next

But whenever I try to access an expression from a list box, it will have an objectID but wont have an object name  ? How can I solve for this problem ?