Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I'm currently using QV11, and trying to do a basic thing through automation.
In a QV Application, there are two different fields : YEAR1 and YEAR2.
User selects one or several values in YEAR1, and then click on a button.
Selection(s) he has done on YEAR1 is/are switched to YEAR2.
My macro does not work, although it matches with everything I already read here :
Sub SwitchFromYEAR1toYEAR2
set fx= ActiveDocument.Fields("YEAR1")
set fxV = fx.GetSelectedValues
set fy= ActiveDocument.Fields("YEAR2")
set fyV = fy.GetNoValues
for i=0 to fxV.Count - 1
fyV.Add
fyV(i).Text = fxV(i).Text
fyV(i).IsNumeric = False
next
fy.SelectValues fyV
end sub
If I add a message box in the loop, I can see that fyV is correctly populated.
But it looks like the instruction fy.SelectValues fyV does not do the selection on YEAR2 (?)
If I test the macro, it looks like there is no error... but also no result ...
Any help would be highly appreciated
Thanks !
Check the changes in the application.
Hi,
you can do this without macro.check with the solution below
Button properties-->Action-->Add-->Select in Field-->
FieldName: Year2
SearchString: ='('&GetFieldSelections(Year1,'|',20)&')'
Celambarasan
Check the changes in the application.
Hi,
Thanks for your quick immediate answer !
Celambarasan,
I also saw this answer but it does not exactly match my 'real' requirements (anyway, I was not precise enough, so you could not know !)
Namit12345,
Thanks it works (it is not the same logic, but it does work)
...although I still do not understand why the first code does not work ...
Finally the code is simply :
Sub SwitchFromYEAR1toYEAR2
set fx= ActiveDocument.Fields("YEAR1")
set fxV = fx.GetSelectedValues
set fy= ActiveDocument.Fields("YEAR2")
fy.SelectValues fxV
end sub
I attach the file, in case it may help someone else
Regards