Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
lmonincx
Creator II
Creator II

use of a variable in a Select vb script

Hi,

I created a variable vMaxWeek containing the last week loaded, i want to create a vb script (macro) which is putting a slection of the field week based on the content of the vMaxWeek.

like: activedocument.Fields("Week").Select "$(vMaxWeek)

But this is not working, has anyone an idea how to work with the content of a variable in VB?

I also tried to use the getvariable but without succes.

Thanks for any help!

Kind regards,
Linda Monincx

1 Solution

Accepted Solutions
Anonymous
Not applicable

Hi Linda,

You can do it like this:

sub test
set v = ActiveDocument.Variables("vTest")
ActiveDocument.Fields("F1").Select v.GetContent.String
end sub

This assumes that you have a variable called vTest and you want to select the matching value from a field called F1.

However, in QlikView 9 there's no need to use a macro for this. Instead this can be achieved with a simple action trigger.

1. Create a button

2. Assign the "Select in Field" action. Point the Field to F1 and the Search string to =$(vTest), and you should get the same result.

View solution in original post

2 Replies
Anonymous
Not applicable

Hi Linda,

You can do it like this:

sub test
set v = ActiveDocument.Variables("vTest")
ActiveDocument.Fields("F1").Select v.GetContent.String
end sub

This assumes that you have a variable called vTest and you want to select the matching value from a field called F1.

However, in QlikView 9 there's no need to use a macro for this. Instead this can be achieved with a simple action trigger.

1. Create a button

2. Assign the "Select in Field" action. Point the Field to F1 and the Search string to =$(vTest), and you should get the same result.

lmonincx
Creator II
Creator II
Author

Great that works thanks for the help! Big Smile

Linda