Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Selection by default

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 😉

1 Solution

Accepted Solutions
Not applicable
Author

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

View solution in original post

11 Replies
Not applicable
Author

Hi,

i have understood from your requirement to select today`s date form the date field Ick!

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 Yes

- Sridhar

Not applicable
Author

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

Not applicable
Author

Tks gordon.savage and sridhar24784

It's working but I want the last day... Huh?

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 Sad)

Not applicable
Author

Hi,

Last day in the sense...?

you mean to say the maximum of the date field...? Confused

Regards

Sridhar

Not applicable
Author

yes it's a possible solution but it's the maximum of date of another table...

Not applicable
Author

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

Not applicable
Author

It's OK

Tks for all your help Yes

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP


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

Anonymous
Not applicable
Author

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...