default date in Prompt

I want to have a prompt so I can filter a report by date. Is it possible to set the default date as today or somehow make it optional so if its left blank then it will filter with todays date?


bension (BOB member since 2005-09-01)

You can put in a macro that pre-populates the date with today’s date. The users will get a message asking if the macro should be enabled - if this confuses or alarms your users, then I’d think twice about it.

The code to pre-populate the prompt would look something like:


Private Sub Document_BeforeRefresh(Cancel As Boolean)
For i = 1 To ActiveDocument.Variables.Count
  If ActiveDocument.Variables.Item(i).IsUserPrompt = True Then
     If ActiveDocument.Variables.Item(i).Name = "Enter As-Of Date (dd/mm/yyyy or dd-MON-yyyy)" Then
        ActiveDocument.Variables.Item(i).Value = Date
     End If     
  End If
Next i

I found this code here on BOB, I think Dwayne posted it. Anyway, hope that helps.

Judy


JMulders :us: (BOB member since 2002-06-20)

Private Sub Document_BeforeRefresh(Cancel As Boolean)
Call Default
End Sub


Sub Default()
For i = 1 To ActiveDocument.Variables.Count
  If ActiveDocument.Variables.Item(i).IsUserPrompt = True Then
     If ActiveDocument.Variables.Item(i).Name = "Enter As-Of Date (dd/mm/yyyy or dd-MON-yyyy)" Then
        ActiveDocument.Variables.Item(i).Value = Date
     End If
  End If
Next i
End Sub

Just tried this. This works fine.
Now having this as a solution, Solves lot of previous threads where members where asking for default prompt value. Well yes this is fine for just Date.


KhoushikTTT :us: (BOB member since 2005-02-24)

Private Sub Document_BeforeRefresh(Cancel As Boolean) 
Call Default 
End Sub 


Sub Default() 
For i = 1 To ActiveDocument.Variables.Count 
  If ActiveDocument.Variables.Item(i).IsUserPrompt = True Then 
     If ActiveDocument.Variables.Item(i).Name = "Enter Country" Then 
        ActiveDocument.Variables.Item(i).Value = "USA" 
     End If 
  End If 
Next i 
End Sub

I tried the above code for a text prompt and it worked fine.


KhoushikTTT :us: (BOB member since 2005-02-24)

Hi,
I am not a VB expert.Please let me know how to implement the code in business objects.
Thanks


harpreet_lucky (BOB member since 2006-04-24)

Private Sub Document_BeforeRefresh(Cancel As Boolean) 
Call Default 
End Sub 


Sub Default() 
For i = 1 To ActiveDocument.Variables.Count 
  If ActiveDocument.Variables.Item(i).IsUserPrompt = True Then 
     If ActiveDocument.Variables.Item(i).Name = [color=red]"Enter Country" [/color]Then 
        ActiveDocument.Variables.Item(i).Value = [color=green]"USA"[/color] 
     End If 
  End If 
Next i 
End Sub

Enter the prompt text in the red colored area and the default value in the green colored area.
Saying that, in your report press F11 and paste this code.


KhoushikTTT :us: (BOB member since 2005-02-24)

Hi,
Sorry but I did not get you.
Please could you explain in detail


harpreet_lucky (BOB member since 2006-04-24)

If ActiveDocument.Variables.Item(i).Name = “Enter Country”

Enter your prompt text here.

and the default prompt value here

ActiveDocument.Variables.Item(i).Value = “USA”


KhoushikTTT :us: (BOB member since 2005-02-24)

Hi Neo,
How are you,
Can this validation of prompts be done iin BOXIR2 without using the Macros,I have a report and here we are asking user to enter the date,if date is entered wrong report should not open like if 11/11/005 is entered by usser instead of 11/11/05,plz help me if it is possible…
Thanks & Regards
Akki…

Note:it’s urgent so respond as soon as possible… :reallymad:


Akash Rochwani (BOB member since 2006-08-29)

The above macro, works fine before the query execution.

I feel it is not possible to do a check on the data entered in the prompt for execution.


KhoushikTTT :us: (BOB member since 2005-02-24)

i try the above code,it did fine in businessobject ,but it didn’t work in infoview. what can i do next? thanks.


bluesprit (BOB member since 2006-07-08)

Doesn’t infoview (I only have experience with infoview 6.1) allow you to save the last used prompt? You won’t need to use this macro then.


jobjoris :netherlands: (BOB member since 2004-06-30)

VBA work in FC , but not in webi.

The one way I know to get the report run with currecnt date is

datefield=(Select case when @variable ('Select Date') >= getdate()   then getdate() else @variable('Select Date') end) 

Put this code in BO generated SQL and check “Do not genereate SQL before running” Box. use getdate for SQL server, Sysdate for Oracle.

Here the report prompt user for a date, if user enters a date which is greater than current date, then the date automatically defaults to Current date internaly and execute the query for current date. otherwise it takes the user entered date and execute the query.

PS. You can change the logic, but keep the syntax same.


shyamdev :japan: (BOB member since 2005-08-05)

However, the base question is yet to be answered.
If we are using Web Intelligence XI, then obviously, VBA cannot be used to set the default date as SYSDATE in a Date Prompt.

Is there any way in which we can set a default value SYSDATE in the Date Prompt in WebI XI ?
Even if we use the extended syntax for Prompt still we can only provide a hard coded date and not something dynamic as the SYSDATE.

Thanks.


biswalamar (BOB member since 2006-01-04)

I am using the following code for my Macro in a desk I report. When I open the report I get an error message saying:
Run-time error ‘91’:
Object variable or With blockvariable not set

Can anyone tell me why?


spark_saaar (BOB member since 2006-09-09)

Hi

When you use the Macro in Desk I report and accessing through infoview, macro will not support.

Regards

Siva.M


looksmee :uk: (BOB member since 2006-02-08)

Hi,

I have a question regarding default value in prompts used by reports in Infoview. Is it possible to make this dynamic?

So when someone opens a report in Infoview and clicks the refresh button so that they can use the prompts, the values in the prompts are the last used values when the report was created in fullclient.

I could clear the prompt value used in the fullclient and save the report and export. This way at least the prompt will be empty whenever the report is started. But the request is that it be dynamic. Is this possible in fullclient reports used in Infoview?

Thanks!
Arash


arashz :netherlands: (BOB member since 2006-06-08)