TextBox calendar on-change event

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #1

    TextBox calendar on-change event

    I'm not sure how to even describe the problem but here I go.

    You know how you can display a date field in such a way that there is a calendar control that is "attached" to a text box that lets an end-user select a date?

    How do you handle the "on change"/ "on update" event for the date?

    I would like to update some sub forms based on a date change without having to click enter or hit the "refresh button" that I've provided to do the job. I was hoping to handle the event in VBA code and execute the method that I already have in place that updates the sub forms.

    -Frinny
  • missinglinq
    Recognized Expert Specialist
    • Nov 2006
    • 3533

    #2
    Frinny, I've read your post several times and I'm still not exactly sure what you're asking. If you simply want to click on a calendar and assign the date to a textbox, without having to use a button as well, you can use the OnClick event of the calendar control:
    Code:
    Private Sub YourCalendarName_Click()
     Me.DateField = Me.YourCalendarName
    End Sub
    If you're using an ActiveX Calendar Control, you have to go into the code module itself to access the OnClick event. Selecting an ActiveX Control and then going to Properties - Events doesn't expose all of the available events for the given control.

    Linq ;0)>

    Comment

    • topher23
      Recognized Expert New Member
      • Oct 2008
      • 234

      #3
      Okay, what I get here is that you have code in a text box's AfterUpdate event, but it doesn't get called because the control's contents are being updated programmaticall y by a calendar control button. My general way of handling that is by calling the AfterUpdate event in code (borrowing linq's code):

      Code:
      Private Sub YourCalendarName_Click() 
       Me.DateField = Me.YourCalendarName 
       DateField_AfterUpdate()
      End Sub

      Comment

      • ADezii
        Recognized Expert Expert
        • Apr 2006
        • 8834

        #4
        You know how you can display a date field in such a way that there is a calendar control that is "attached" to a text box that lets an end-user select a date?
        Hello Frinavale. I know exactly what you are referring to and it is called the DatePicker Control. This Control combines the functionality of a Textbox and a Calendar all rolled into one, to support both Novice and Power users. The User can easily select or manually enter a Date, there is no worry about Date Formatting, it is highly customizable, knows about Leap Years, and has built in Validation. I'm not exactly sure of what specific Events that this Control exposes, but it should be a simple matter to look it up if you are interested.

        Comment

        • Frinavale
          Recognized Expert Expert
          • Oct 2006
          • 9749

          #5
          Thank you ADezii.
          I didn't know what it was called :)

          I'll look into it!
          (Probably not for a few days though, my evenings are booked right now)

          -Frinny

          Comment

          • topher23
            Recognized Expert New Member
            • Oct 2008
            • 234

            #6
            Ahh... is this the third-party OCX control, or the one I've heard comes built-in with Access '07?

            I like to use Stephen Lebans' calendar, a text box and a button to make my date pickers. I guess I'm just old-fashioned that way, but custom ActiveX controls bug me.

            Comment

            • ADezii
              Recognized Expert Expert
              • Apr 2006
              • 8834

              #7
              You may find this very interesting, take a look:

              Comment

              • mshmyob
                Recognized Expert Contributor
                • Jan 2008
                • 903

                #8
                Just ran across this post. Frin can you just not use the events for the control that is set to date. For instance you have a text box control that is formatted for 'short date' and 'show date picker'. After selecting a date from the date picker you would have an 'After Update' or any other event for the text box.

                Would that not work?

                cheers,

                Comment

                Working...