+ Reply to Thread
Results 1 to 13 of 13

Date picker to show todays date HELP!!!!

  1. #1
    Forum Contributor
    Join Date
    07-02-2013
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    109

    Date picker to show todays date HELP!!!!

    Hi all,

    I have a date picker on a user form & i need it to show todays date which i think is acheived by placing Me.Datepicker1.Value = Date in the inialize part but im stuck on where that actually is. When i right click on userform in the VBA editor i then click on view code & the following is shown:

    Please Login or Register  to view this content.
    Where do i need to place it???

    Thanks,

    Tony.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Date picker to show todays date HELP!!!!

    It looks like you don't yet have a UserForm initialize procedure.

    Add this in the userform code module with the other procedures

    Please Login or Register  to view this content.
    Do not change the procedure name to UserForm1_Initialize
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Contributor
    Join Date
    07-02-2013
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    109

    Re: Date picker to show todays date HELP!!!!

    Quote Originally Posted by AlphaFrog View Post
    It looks like you don't yet have a UserForm initialize procedure.

    Add this in the userform code module with the other procedures

    Please Login or Register  to view this content.
    Do not change the procedure name to UserForm1_Initialize
    Fantastic, thanks

    Tony.

  4. #4
    Forum Contributor
    Join Date
    07-02-2013
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    109

    Re: Date picker to show todays date HELP!!!!

    Quote Originally Posted by AlphaFrog View Post
    It looks like you don't yet have a UserForm initialize procedure.

    Add this in the userform code module with the other procedures

    Please Login or Register  to view this content.
    Do not change the procedure name to UserForm1_Initialize
    Oh no it did work but if i change any thing within the user form i then get the following error:

    "Run time error 35788
    An error occured in a call to window date & time picker control"

    Then if i Debug it takes me to the the show userform module & yellow's the second line:

    Please Login or Register  to view this content.
    If i change userform to userform1 it works again but the date is wrong????

    Thanks,

    Tony.

  5. #5
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Date picker to show todays date HELP!!!!

    The procedure Sub ShowUserForm() should be located in a standard code module (e.g. Module1) and not in the UserForm's code module.

  6. #6
    Forum Contributor
    Join Date
    07-02-2013
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    109

    Re: Date picker to show todays date HELP!!!!

    Quote Originally Posted by AlphaFrog View Post
    The procedure Sub ShowUserForm() should be located in a standard code module (e.g. Module1) and not in the UserForm's code module.
    The Sub ShowUserForm() is in Module 5.

  7. #7
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Date picker to show todays date HELP!!!!

    What does the user do to start the user form; is it a button on the worksheet, or what? Can you show that code? Or upload your workbook.

  8. #8
    Forum Contributor
    Join Date
    07-02-2013
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    109

    Re: Date picker to show todays date HELP!!!!

    Quote Originally Posted by AlphaFrog View Post
    What does the user do to start the user form; is it a button on the worksheet, or what? Can you show that code? Or upload your workbook.
    To start the user form the macro

    Please Login or Register  to view this content.
    Is assigned to a button on the worksheet. If i run this macro without the button it still fails now. It only fails if i make a change to the use form after adding the datepicker code which i placed here:

    Please Login or Register  to view this content.

  9. #9
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Date picker to show todays date HELP!!!!

    I don't see a problem with the code. Attach a workbook.

  10. #10
    Forum Contributor
    Join Date
    07-02-2013
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    109

    Re: Date picker to show todays date HELP!!!!

    test.xlsm

    I have attached a cutdown version i.e i have removed all the info which the worksheet looks for but the functionality is still there. You will see that the date is now correct but if you change anything on the userform like for example make it bigger then this when the problem occurs!!!

  11. #11
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Date picker to show todays date HELP!!!!

    Your file works for me. No error. I'm using Excel 2003.

    I don't think you have a problem with your code. I've read a few threads where some people have issues with the DTPicker control in 2007 and later, but I don't have a solution for you. Do a web search for something like Excel 2007 DTPicker and you will find other threads about it.

  12. #12
    Forum Contributor
    Join Date
    07-02-2013
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    109

    Re: Date picker to show todays date HELP!!!!

    Quote Originally Posted by AlphaFrog View Post
    Your file works for me. No error. I'm using Excel 2003.

    I don't think you have a problem with your code. I've read a few threads where some people have issues with the DTPicker control in 2007 and later, but I don't have a solution for you. Do a web search for something like Excel 2007 DTPicker and you will find other threads about it.
    Ok thank you i will have a google or i may have to scrap the date picker for manual date entry?

    Thanks again for your help.

    I will leave the thread unsolved incase anyone else has any ideas if thats ok????

    Tony.

  13. #13
    Forum Contributor
    Join Date
    07-02-2013
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    109

    Re: Date picker to show todays date HELP!!!!

    Quote Originally Posted by Bflare View Post
    Ok thank you i will have a google or i may have to scrap the date picker for manual date entry?

    Thanks again for your help.

    I will leave the thread unsolved incase anyone else has any ideas if thats ok????

    Tony.
    Solved

    I googled it & someone suggested using the control "Calendar Control 12.0" for Excel 2007 & above & it works great.

    Thansk,

    Tony.

+ 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. Replies: 7
    Last Post: 12-08-2013, 06:11 PM
  2. CF to colour cells that show a date approaching todays date
    By alexander.small in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-24-2013, 05:23 AM
  3. [SOLVED] Have code for userform calendar but will not show todays date, please help
    By Jeff up North in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-05-2013, 03:05 PM
  4. Replies: 1
    Last Post: 07-01-2010, 11:32 AM
  5. Using VB to find a range based on todays date and todays date +30
    By Steve_al in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-13-2009, 09:31 AM

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