BusinessObjects Board

Date Prompts validation

Hello,

I did search, but could not find anything simular for my problem.
I have Date Prompts on reports, and clients required to validate the Prompts before reports are refreshing.
The format for the Dates is mm/dd/yyyy; if you type mm/dd report is refreshing for the current year. How to add validation to the Prompt?
How to have user to type needed Date’s format?
Thank you very much for the help in advance.

[Moved to SDK (Programming Forum) where the issue can be resolved- RM]


darina (BOB member since 2002-12-03)

You can use a macro - “intercept” the input within the BeforeRefresh action and, if necessary, set the “Cancel” param to True if the format is incorrect, and display feedback to the user.


Dorota Woodbury :us: (BOB member since 2005-02-23)

Dorota,

I am new in macro. Please send me any code samples if you have.
Thank you for the quick responce.


darina (BOB member since 2002-12-03)

This is just an example –

Private Sub Document_BeforeRefresh(Cancel As Boolean)
    Dim userDate As String
    userDate = UserResponse("MyUniverse", "MyPrompt")
    Dim year As String
    year = Right(userDate, 4) 
    ' this should prevent date like 10/10/100 from being accepted
    If Not(IsDate(userDate)) Or Len(userDate) > 10 Or Len(userData) < 8 Or  Not(IsNumeric(year)) Then
        Cancel = True
        MsgBox ("You must enter the date in the 'mm/dd/yyyy' format.")
    End If
End Sub

Dorota Woodbury :us: (BOB member since 2005-02-23)

Thank you.
Do I need to create a form instead of Prompt?
What I’ve learned from reading the topics it is no way to do validation without creating the form.


darina (BOB member since 2002-12-03)

Also for UserResponse function I am getting compilation error
“Sub or Function not defined”
Thank you.


darina (BOB member since 2002-12-03)

Sorry! Please replace UserResponse (BO function) with Application.Variables(“variable_name”).Value. I’m not positive if it’ll work with @prompt or only @variable (with @variable you can’t “cast” it to a specific data type – but you validate it within the macro).

Dorota


Dorota Woodbury :us: (BOB member since 2005-02-23)

You may have no choice but to display a form on BeforeRefresh, and, in case of invalid user input, set the Cancel param to True…
Dorota


Dorota Woodbury :us: (BOB member since 2005-02-23)

Thank you very much for your help


darina (BOB member since 2002-12-03)

If you could elaborate little more about this solution, where exactly I need to do this change?
which form you are referring here?
Kindly reply.

Do realize this thread is 17 years old? I would recommend posting a new question.

1 Like