Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
Sorry for my bad english
I want to have a selection by default when I open qlik file...
I want to select data of the "d" day
How I can do this...
Thanks for your help 😉
Hi,
Use the below code for that scenario.
sub test()
set f = ActiveDocument.GetField ("Date")
f.TopSelect "max (Date)", 1
End sub
check the attached application.
Regards
Sridhar
Hi,
i have understood from your requirement to select today`s date form the date field ![]()
If my understanding is correct, following code will help you to do the same.
sub Select_Date()
Dim vDate
vDate = day(date) &"/"& month(date) &"/"& year(date)
ActiveDocument.Fields("Date").Select vDate
End sub
Map this function to onopen in Document event trigger in document settings .
Check the attached application.
Good Luck ![]()
- Sridhar
If you are using the document in server environment, 'onopen' has no meaning. You can have the macro fire by passing the name in the URL though:
qvp://servername/documentname.qvw?MACRO=Select_Date()
Regards,
Gordon
Tks gordon.savage and sridhar24784
It's working but I want the last day... ![]()
I don't know how calculate the last day with the function day()
I have do this :
sub Select_Date()
Dim vYear ,vMonth,vDay
vYear = year(date)
ActiveDocument.Fields("CALENDAR.annee").Select vYear
vMonth= month(date)
ActiveDocument.Fields("CALENDAR.month").Select vMonth
vDay= day(date)
ActiveDocument.Fields("CALENDAR.day").Select vDay
End sub
And if i do vDay=day(date)-1 it's not work for the first day of month (01/05/2009 -> 00/05/2009
)
Hi,
Last day in the sense...?
you mean to say the maximum of the date field...? ![]()
Regards
Sridhar
yes it's a possible solution but it's the maximum of date of another table...
Hi,
Use the below code for that scenario.
sub test()
set f = ActiveDocument.GetField ("Date")
f.TopSelect "max (Date)", 1
End sub
check the attached application.
Regards
Sridhar
It's OK
Tks for all your help ![]()
gordon.savage wrote:If you are using the document in server environment, 'onopen' has no meaning
I know the doc says not to use OnOpen in the server environment. But...I always do use it for initial selections. I'll bet many others do, and it works.
Does anyone have thoughts about using OnOpen in QVS to make initial selections? (I'm only talking doing Selects - not properiy changes). Is it really possible that it won't work some day?
-Rob
I'm using initial selections on open in most apps, including on server, and it never fails. Well, unless user blocks the macros, of course...