+ Reply to Thread
Results 1 to 10 of 10

Date Picker Default Value

  1. #1
    Registered User
    Join Date
    07-17-2017
    Location
    Boston, MA
    MS-Off Ver
    365
    Posts
    55

    Date Picker Default Value

    I am using the Microsoft Date and Time Picker Control 6.0. How do I set the default date to today when the form initializes? Alternatively, is there a better date picker to use since I've heard that there can be a portability issue with this one?

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Date Picker Default Value

    Hi jeetkapadia

    I've done a fair amount of work in this area. I'd suggest a non ActiveX Calendar Control. Here are several Links to examples...if you need help adapting let me know.
    https://www.excelforum.com/excel-pro...-workbook.html
    https://www.excelforum.com/excel-pro...ternative.html
    https://www.excelforum.com/excel-pro...userforms.html
    https://www.excelforum.com/excel-pro...-calendar.html
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Registered User
    Join Date
    07-17-2017
    Location
    Boston, MA
    MS-Off Ver
    365
    Posts
    55

    Re: Date Picker Default Value

    Hi jaslake,

    I tried to use a couple of automatic ones but I guess that just won't work well. Can you tell me what I need to do to adapt the one that you have posted? All I want to do is have a textbox on the form show today's date on form initialization, and when clicked on, the calendar pops up like the 'DateTest' you share.

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Date Picker Default Value

    Hi jeetkapadia

    The attached has a Simple User Form with a Textbox that does this...
    All I want to do is have a textbox on the form show today's date on form initialization, and when clicked on, the calendar pops up like the 'DateTest' you share.
    If you need help adapting you'll need to attach your File.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    07-17-2017
    Location
    Boston, MA
    MS-Off Ver
    365
    Posts
    55

    Re: Date Picker Default Value

    Hi jaslake,

    I got it to work, but when does this sub activate?
    Please Login or Register  to view this content.
    As in, what is the 'enter' action? One problem I'm running into is that when a date is entered, and the calendar closes, the cursor still blinks in the date box. So if you want to reopen the calendar, you have to click elsewhere, then click on the calendar text box again for it to show up. Clicking there while the cursor already blinks does not work. Is there any way to work around it other than shifting focus when the calendar closes? I've got the file on here if you want to take a look. The date is on the form 'Structural'
    Attached Files Attached Files
    Last edited by jeetkapadia; 08-01-2017 at 04:16 PM.

  6. #6
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Date Picker Default Value

    Hi jeetkapadia

    Firstly, your Workbook didn't include the Class Module...it's been incorporated into the attached. In the Class Module I've modified this Line of Code to correspond to your Form Initialize Format...
    Please Login or Register  to view this content.
    Secondly, in the User Form Initialize Event I've added this Line of Code...you may or may not want that...
    Please Login or Register  to view this content.
    Thirdly, regarding this...it's dependent on the Tab Order or Set Focus Order you've set...
    what is the 'enter' action
    As I don't know what Tab order you prefer, to set the Tab Order, right click on the User Form (in VBA) and move the Objects Up or Down as you see fit.

    Let me know how I can help.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    07-17-2017
    Location
    Boston, MA
    MS-Off Ver
    365
    Posts
    55

    Re: Date Picker Default Value

    Hi jaslake,

    Thanks for your help! I think I didn't explain myself very well. When I select a date on the calendar and the calendar closes, the cursor is on the date textbox. So if I want to open the calendar again I need to click outside and then click on the textbox again to open it. Is there some way to change that?

  8. #8
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Date Picker Default Value

    Hi jeetkapadia

    Add the indicated Line of Code to Sub PlateDate_Enter...
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    07-17-2017
    Location
    Boston, MA
    MS-Off Ver
    365
    Posts
    55

    Re: Date Picker Default Value

    Hi jaslake,

    Thank you for all your help! I love the date calendar you've made and will probably go through all the code to see how it works :D

  10. #10
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Date Picker Default Value

    Hi jeetkapadia

    You're welcome...glad I could help. Thanks for the Rep.

    Unfortunately I can't take credit for being my Code...found it through Google and adapted to my needs.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Change Date with Date Picker If Date Less Than 7 Days From Another Date
    By Macfool in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-16-2016, 09:10 AM
  2. Replies: 5
    Last Post: 04-06-2016, 06:58 AM
  3. Add Date to User Form Without Access to Add Date Picker Control
    By kaleonard08 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-01-2016, 12:06 PM
  4. Date picker used to populate text box. Date changes back to original value on opening.
    By Stratfordoaks in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-07-2016, 09:42 AM
  5. [SOLVED] file-picker thinks it is a folder-picker if the folder picker runs first?
    By brucemc777 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-01-2016, 01:14 PM
  6. Replies: 0
    Last Post: 08-01-2015, 12:29 AM
  7. Replies: 7
    Last Post: 12-08-2013, 06:11 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1