Textbox Calendar Limiting

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jerryruthj
    New Member
    • Jun 2016
    • 7

    Textbox Calendar Limiting

    I have a textbox that i use as a calendar option. The text box populates the calendar option on the right. When clicked a Calendar picker type option appears. I'd like to be able to limit to only allow the user to pick current day to days before. Hope this makes sense.
  • TheSmileyCoder
    Recognized Expert Moderator Top Contributor
    • Dec 2009
    • 2322

    #2
    You can't limit the datepicker to prevent a user from CHOOSING a date in the future, but you CAN prevent the user from SAVING it.

    In the CONTROLS Before_Update event you can do:
    Code:
    Private Sub DateControl_BeforeUpdate(Cancel as Integer)
      If Isnull(me.DateControl) then exit sub 'This allows the user to blank out the control
      if Me.DateControl>Date() then
         Cancel=True 'This stops the user from saving
         msgbox "The date entered lies in the future, please correct"
      End If
    End Sub

    Comment

    • jerryruthj
      New Member
      • Jun 2016
      • 7

      #3
      Thank you! That was exactly what i needed.

      Comment

      Working...