+ Reply to Thread
Results 1 to 12 of 12

Text box validation - date entry - format "dd mm yyyy"

  1. #1
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Text box validation - date entry - format "dd mm yyyy"

    Hi I am trying to tie down users to only entering a date in the correct format in a number of text boxes on a userform.
    I'm nearly there but am trying to code for the event where a date will have the correct number of characters but with no spaces or if "-" and "/" are used.

    The attached example seems to go so far but if the date "10 03 2016" is entered as "10032016" then an error is thrown highlighting line

    Please Login or Register  to view this content.
    Any pointers appreciated
    Attached Files Attached Files
    Last edited by nigelog; 05-25-2017 at 06:13 AM.

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: Text box validation - date entry - format "dd mm yyyy"

    Please Login or Register  to view this content.
    ?

  3. #3
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Re: Text box validation - date entry - format "dd mm yyyy"

    Thanks Jindon, thats perfect. I'll look now at how to restrict use of "/" and "-"

    This cured the "10031962" by correctly formatting as "10 03 1962"

    But, if numeric incorrect date entered "1003" this gets formatted as "00 00 1003" rather than a message box warning which is required.

    Can the entry be restricted to two blocks of 2 digits and a block of 4 digits all separated by spaces ?


    Made slight change and getting to the stage where liveable...Many thanks

    Please Login or Register  to view this content.
    Last edited by nigelog; 05-25-2017 at 06:12 AM.

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: Text box validation - date entry - format "dd mm yyyy"

    Dates are always troublesome...
    If you want to accept the data like

    10 10 2017, 10/10/2017, 10-10-2017, 10,10,2017, 10.10.2017
    Please Login or Register  to view this content.
    However, it still accepts the numbers that is not date like 00000000.
    I would suggest to use 3 comboboxes for Year/Month/Date input...

  5. #5
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Re: Text box validation - date entry - format "dd mm yyyy"

    Thanks Jindon, hadn't seen your second post. Thanks for the input I'll have a look at what works on the instance
    I'll look into the combo boxes
    Had tried datepicker but found it fickle with certain dates

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: Text box validation - date entry - format "dd mm yyyy"

    I found the Data Picker is unstable.
    Here's an example of comboboxes just made for someone else.

    Just for the idea.
    Attached Files Attached Files

  7. #7
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Re: Text box validation - date entry - format "dd mm yyyy"

    Thanks Jindon
    I'm going to look at possibly using one instance of that ComboCalender, triggered by a focus event, to populate all date text boxes....just need to figure how to paste the result back into the first Userform...

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: Text box validation - date entry - format "dd mm yyyy"

    Are you using date input form from multiple userforms? or just from one userform?

  9. #9
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Re: Text box validation - date entry - format "dd mm yyyy"

    Hi Jindon
    2 userforms, one is multipage, all text box references unique to the page
    both userforms in same workbook

    Have the amended comboCalendar launching on text box select - have added a command button, just need that to write back to the userform
    Attached Files Attached Files
    Last edited by nigelog; 05-25-2017 at 08:43 AM.

  10. #10
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: Text box validation - date entry - format "dd mm yyyy"

    This will give you an idea calling date input form from multiple user form.

    See the code in each userform.
    Attached Files Attached Files

  11. #11
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Re: Text box validation - date entry - format "dd mm yyyy"

    Many thanks Jindon, plenty to work with..

  12. #12
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: Text box validation - date entry - format "dd mm yyyy"

    You are welcome and thanks for the rep.

    If you get stuck, just post back.

+ 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] Userform Dynamically Generated Combobox format value as date ("mm/dd/yyyy")
    By CieloSalas in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-12-2017, 03:39 PM
  2. Replies: 8
    Last Post: 06-21-2016, 08:56 AM
  3. "Please enter a date in the format dd/mm/yyyy" error
    By marcelotero in forum Excel General
    Replies: 2
    Last Post: 08-18-2015, 12:23 PM
  4. Replies: 1
    Last Post: 12-11-2013, 10:35 AM
  5. Replies: 3
    Last Post: 08-13-2013, 06:25 AM
  6. Replies: 0
    Last Post: 08-09-2012, 04:31 PM
  7. convert string to date format of "d-mmm-yyyy"
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-12-2011, 09:48 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