Form Calendar Help

  • Thread starter Thread starter Rob
  • Start date Start date
R

Rob

Ok so i need to put a calendar so they can pick what day the employee was
scored on. But i don't want them to be able to pick any day past 7 days back.
any clue on how i would do it in code ect.

Thank you,
 
You need a BeforeUpdate event for the calendar object. For some reason the
events that you see in the calendar properties are very limited when you're
in Form design view. If you view the code for the form and select the
calendar object in the objects dropdown near the top left, the various events
for it should show up in the events dropdown near the top right. Select
BeforeUpdate and it should get the sub started for you. Then just check the
date value that was selected and set Cancel = True if the date is more than 7
days ago. NOTE: WHen referencing the value selected from the calendar you
need to reference it as cal.Object.Value.

e.g. if your calendar object is called cal, code something like this:

Private Sub cal_BeforeUpdate(Cancel As Integer)

if cal.Object.Value < Date() - 7 then
msgbox "You must select a date value withi the past week."
Cancel = True
end if

End Sub
 
Back
Top