Friday, July 27, 2012 7:12 AM
Is there a way to prevent users from entering back dated values ?
I used the following code, but a change in system date will make it void, I have a field called Tdate (TDate = Today).
Private Sub Tdate_Validate(results As EntityValidationResultsBuilder)
If Tdate < Today Then
results.AddPropertyError("Date cannot be backdated")
If Tdate > Today Then
results.AddPropertyError("Date cannot be future dated")
- Edited by M.Prasad Friday, July 27, 2012 7:18 AM change
Friday, July 27, 2012 10:31 AM
With my applications, I use an additional date test. Get the latest saved date from Tdate and:
dim latestDate = MyCollection.Max(Function(n) n.TDate)
If (Tdate < Today) OrElse (Tdate < latestDate) then
You can improve this method: every time that your application is openned, save the current date and used it to avoid back date input.
I hope it helps you.
Friday, July 27, 2012 11:34 AMModeratorIf you don't want dates prior to today's date, & you also don't want dates that are after today's date, why don't you just set the property to today's date in the EntityName_Created method, then make the property read-only on the screen?
Yann - LightSwitch Central - Click here for FREE Themes, Controls, Types and Commands If you find a reply helpful, please click "Vote as Helpful", if a reply answers your question, please click "Mark as Answer" By doing this you'll help people find answers faster.