Hi all, I have got a piece of code which sets the date on a control on my InfoPath form (VBScript and IP 2003). The code I have is...
Dim dtTargetComplete
dtTargetComplete = XDocument.DOM.selectSingleNode ("/dfs:myFields/my:TargetCompleteDate").text dtTargetComplete = DateAdd("d",7,now)
if XDocument.DOM.selectSingleNode ("/dfs:myFields/my:TargetCompleteDate").removeAttribute("xsi:nil") then
XDocument.DOM.selectSingleNode ("/dfs:myFields/my:TargetCompleteDate").text = FormatDateTime(dtTargetComplete,2)
else XDocument.DOM.selectSingleNode ("/dfs:myFields/my:TargetCompleteDate").text = FormatDateTime(dtTargetComplete,2)
end if
Now this code works OK, and correctly sets the date in the contol. But when the date is set in the control, the control appears with dotted red border, as with a validation error. If I then make a slight edit to the data in the contol (eg replace 2009 with 2009) then the validation error disappears. The control is defined as a Date, not a text or number.
Does anyone know how to avoid this validation error when setting dates from Code. Many thanks!