Preventing calendar start overlapping end date etc

Has anyone got a good foolproof method of stopping two calendar dates overlapping whilst displaying the selected dates? I can have some script display a message if the ‘start’ date is after the ‘end’ date etc and stop the selected date from getting to the ‘report’ start/end date but the calendar still displays the out-lawed date chosen rather than revert back to what was originally selected. If I use a message box to inform the user this has to be acknowledged twice and the script gets run again by the propertyChange :scratch:

Don’t suppose there is a way of shading out the ‘out-lawed’ dates like web pages usualy do i.e. the return calendar stops you even seeing dates before the depart date?

[code]if event.propertyName == “date”:
from java.util import *

start = event.source.parent.getComponent('startDate').date
end =

startYear = system.db.dateFormat(start, "yyyy")
startMonth = system.db.dateFormat(start, "MM" )
startDay = system.db.dateFormat(start, "dd" )
startHour = system.db.dateFormat(start, "HH" )
startMinute = system.db.dateFormat(start, "mm")
startSeconds = system.db.dateFormat(start, "ss" )

calStart = Calendar.getInstance()
calStart.set(Calendar.YEAR, int(startYear))
calStart.set(Calendar.MONTH, int(startMonth)-1)
calStart.set(Calendar.DAY_OF_MONTH, int(startDay))
calStart.set(Calendar.HOUR_OF_DAY, int(startHour))
calStart.set(Calendar.MINUTE, int(startMinute))
calStart.set(Calendar.SECOND, int(startSeconds))

endYear = system.db.dateFormat(end, "yyyy")
endMonth = system.db.dateFormat(end, "MM" )
endDay = system.db.dateFormat(end, "dd" )
endHour = system.db.dateFormat(end, "HH" )
endMinute = system.db.dateFormat(end, "mm")
endSeconds = system.db.dateFormat(end, "ss" )

calEnd = Calendar.getInstance()
calEnd.set(Calendar.YEAR, int(endYear))
calEnd.set(Calendar.MONTH, int(endMonth)-1)
calEnd.set(Calendar.DAY_OF_MONTH, int(endDay))
calEnd.set(Calendar.HOUR_OF_DAY, int(endHour))
calEnd.set(Calendar.MINUTE, int(endMinute))
calEnd.set(Calendar.SECOND, int(endSeconds))

now2 = Calendar.getInstance()
now = now2.getTime()
print "1"
if endTime.after(startTime) and endTime.before(now):
	event.source.parent.endDate = endTime
	event.source.test = 0
	print "2"
elif endTime.after(now):
	if event.source.test == 0:
		system.gui.messageBox("End Time Cannot Be After Now, Reselect Another End Date","End Date Error" )
		event.source.test = 1 = event.oldValue
		print "3"						
elif endTime.before(startTime):
	if event.source.test == 0:
		system.gui.messageBox("End Time Cannot Be Before Start Time, Reselect Another End Date","End Date Error" ) = event.oldValue
		event.source.test = 1 = event.oldValue
		print "4"[/code]

Put the above code in and when the end date is before now etc (good) the console shows:
When a put in an end date in the future (wrong) the console shows:
1 waits with messageBox displayed, click OK
1,2,3,1 waits with messageBox displayed, click OK

:scratch: My very limited knowledge of python says that an if elif routine breaks if one ‘if’ is true so how can I ever get 2 followed by a 3??? :scratch:

Yes, if and elif statements that are at the same tab level will be exclusive. getting a 2 and a 3 with this script should not be possible without another 1 in there. Are you sure both the 2 and 3 are coming from the same script? Can you change them to a,b,c and see if you get the same behavior?

A solution was found that worked.