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