Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Select From Date to Date

Hi, I have two variables vDateIni, vDateFin

I want to make a button that selects the values from date ini to date fin

Sub openPeriodo

    dim vIni,vFin,cadena

    set cadena = chr(10)     'str '' blank

    set vIni = ActiveDocument.Variables("vDateIni")

    set vFin = ActiveDocument.Variables("vDateFin")

    for i = CLng(vIni.GetContent.string) to CLng(vFin.GetContent.string)

      set cadena = CStr(cadena) & CStr(i) & chr(44)   '44 is comma

    next

    ActiveDocument.Fields("numFecha").Select CStr(cadena)

End sub

My macro doesn´t work, fails

Anybody can help me?

1 Solution

Accepted Solutions
vgutkovsky
Master II
Master II

The problem with doing this with a macro is that you lose the ability to make it work in AJAX. I would create a button with a "Select in Field" action instead. Use "numFecha" as your field name. For search string, enter the following: ='>=$(vDateIni)<=$(vDateFin)'

Regards,

Vlad

View solution in original post

5 Replies
dwh1104
Creator II
Creator II

Try something like this...

sub SetDateRange
set StartDt = ActiveDocument.Variables("StartDate")
set EndDt = ActiveDocument.Variables("EndDate")
set PostDt = ActiveDocument.Fields("Post Date")
PostDt.Select ">=" + StartDt.GetContent.string + "<=" + EndDt.GetContent.string
end sub

vgutkovsky
Master II
Master II

The problem with doing this with a macro is that you lose the ability to make it work in AJAX. I would create a button with a "Select in Field" action instead. Use "numFecha" as your field name. For search string, enter the following: ='>=$(vDateIni)<=$(vDateFin)'

Regards,

Vlad

Not applicable
Author

Hi Dan, Thanls a lot for your answer but I prefer the answer of Vlad that is better for me.

Not applicable
Author

Hi Vlad, your system is better for me. it work´s fine.Thanks a lot.

dwh1104
Creator II
Creator II

I also like Vlad's suggestion better.  We don't use AJAX currently, but I do like the idea of avoiding macros whenever possible.

Thanks,

Dan