Results 1 to 14 of 14
  1. #1
    Rin is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2018
    Posts
    9

    Question Date Picker Events

    I have a date picker on my form and I want to update some stuff whenever the user changes the date. I've tried using the On Updated event, but that event doesn't seem to fire when a new date is picked. What am I missing?

    Thanks in advance,

    ~Rin

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    After update will work once you have left that control.
    Click Enter to see the effect or click on another control
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    or try the change event - but if the user types a date, it will fire everytime they enter a character - but you can use the isdate function to check if it is a valid date

    if isdate(datectrl.text) then
    'update some stuff
    end if

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    I've found that the reason many users prefer typing in a date is that they don't want to have to click on the calendar icon and then click on a date. I've gotten around this, with great success, by having the calendar automatically popping up when the date field receives Focus. The code to do this (and to move Focus to another Control, causing the AfterUpdate event to fire) is simple:

    Code:
    Private Sub DateField_GotFocus()
      DoCmd.RunCommand acCmdShowDatePicker
    End Sub
    
    Private Sub DateField_Change()
      Me.AnotherControl.SetFocus
    End Sub
    
    Private Sub DateField_AfterUpdate()
      'AfterUpdate code goes here
    End Sub


    If the date Control happens to be the first Control to receive Focus...you'll need these two bits of code, as well:
    Code:
    Private Sub Form_Load()
      Me.TimerInterval = 1
    End Sub
    
    Private Sub Form_Timer()
      Me.TimerInterval = 0
      Me.DateField.SetFocus
      DoCmd.RunCommand acCmdShowDatePicker
    End Sub


    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    Rin is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2018
    Posts
    9
    Thanks for the suggestions to use the Change even, but there isn't one. The only events available for the native date picker control in Access 2016 are on Update, Enter, Exit, Got Focus, and Lost focus. From experimentation, it seems that Update fires on Lost focus. While the best solution would be for Microsoft to step up with a Change event, we all know that's not going to happen or it already would have.

    Other threads on this forum suggest using a third party date picker and that really seems to be the only solution. I hate to do it because I really prefer the simple appearance of the MS date picker, but I don't see any way around it.

    Thanks for the input folks.

    ~Rin

  6. #6
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Ajax was referring to the change event in the textbox but I would still recommend the After update event
    The MS date picker is simple but that's also its weakness.
    For example if you want to change to a date in 2010 you have to scroll back month by month almost 100 times
    That's one reason why a lot of people prefer to type in their own date

    Have a quick look at my Better Date Picker - very easy to use and its ...better IMHO http://www.mendipdatasystems.co.uk/b...ker/4594398118
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  7. #7
    Rin is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2018
    Posts
    9
    @ridders52,

    The Change event from the unbound textbox with a date data type doesn't fire when a date is selected from the associated date picker. It only fires when a date is typed in.

    Thanks for the link to that date picker. I'll check it out. It's been a lot of years since I've used a control that wasn't native in Access so I may need some knowledge updates on how to do that.

    Thanks for the help,

    ~Rin

  8. #8
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    For that reason, you ideally want everyone to type in the date or nobody.
    By using a good date picker, the problem should be solved
    My version is clearly explained at the link I supplied and as I said very easy to use

    For info, mine is not an ActiveX control. It works in any Aceess version and in both 32-bit and 64-bit Access.
    Last edited by isladogs; 12-04-2018 at 03:40 AM.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  9. #9
    Rin is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2018
    Posts
    9
    @ridders52,

    I'm having trouble adding the control. Probably because I don't really know what I'm doing. I put it into a folder in the MicorsoftOffice/root/Office16/ADDINS directory. I ran the Add-in manager as and administrtor), navigated to the directory, and selected "All Files" to see the control (the .accdb extension wasn't in the list). I tried too add it and got an error saying that the add-in couldn't be installed because it's missing the USysRegInfo table.

    Clearly I'm doing something wrong.

    ~Rin

  10. #10
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Its not an add-in
    The instructions were on the link I supplied:

    To use, copy frmDatePicker & modDatePicker to your own database

    Its main purpose is to input a date in a form textbox
    All you need for that is one line of code in your textbox click event:
    For example

    Code:
    Private Sub txtDate_Click()
       InputDateField txtDate, "Select a date to use this on your form"
    End Sub
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  11. #11
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    Quote Originally Posted by Rin View Post
    @ridders52,

    The Change event from the unbound textbox with a date data type doesn't fire when a date is selected from the associated date picker. It only fires when a date is typed in.
    Sorry...that's simply not true! The code I gave was tested on both a Bound and Unbound Textbox formatted/defined as a DateTime Field.

    You have to be doing something incorrectly.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  12. #12
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Whilst linq is correct, using the Change event is a bad idea if anyone enters or edits the dates direct as it will fire repeatedly.
    After update will only fire once whether the date is entered using a date picker or entered direct.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  13. #13
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    That's true...but I've never had a problem with that, in the apps I've designed. As I said, once the DatePicker pops up automatically, relieving the user of having to use the mouse to bring it up, users, in my experience, prefer to use it over a bunch of characters.

    Colin makes a good point about entering grossly historic dates, i.e. ones far in the past...the native DatePicker is not the way to go...but for entering near current dates, it's perfect.

    As is often the case...it's a matter of picking the right tool for the job!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  14. #14
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    As my users often have to pick dates well in the past or future, the built-in date picker isn't up to the job...which is why I rolled my own

    I also rarely use the change event but on very rare occasions I've had to resort to code like this to ensure it fired no matter how data was modified

    Code:
    Public Sub txtMessage_AfterUpdate() 
    'This is public so it can be called externally
        txtMessage_Change
        
    End Sub
    Can't remember what the reason was in that case
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Date picker
    By Jen0dorf in forum Access
    Replies: 1
    Last Post: 03-11-2016, 10:54 AM
  2. Replies: 11
    Last Post: 06-28-2015, 06:42 PM
  3. Show Date Picker on Load and Verifying Date
    By Markb384 in forum Forms
    Replies: 4
    Last Post: 03-04-2014, 07:44 AM
  4. Date criteria using between and form date picker
    By killermonkey in forum Queries
    Replies: 3
    Last Post: 03-21-2013, 12:44 PM
  5. Date picker
    By SFC in forum Forms
    Replies: 2
    Last Post: 02-07-2012, 04:00 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums