+ Reply to Thread
Results 1 to 4 of 4

Date validation does not work on text box

  1. #1
    Registered User
    Join Date
    08-15-2015
    Location
    Usa
    MS-Off Ver
    2013
    Posts
    12

    Date validation does not work on text box

    Hi there,

    I'm trying to run a date validation on text box but it does not work the way it should work. Here is the code. Could someone help?


    Private Sub dobtbox_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    If dobtbox = vbEmptyString Then Exit Sub
    If IsDate(dobtbox) Then
    dobtbox = Format(dobtbox, "mm/dd/yyyy")
    Else
    MsgBox " Please enter a valid date", vbCritical
    End If
    End Sub

    Thank you

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,598

    Re: Date validation does not work on text box

    No examples of dates that don't work, so....
    Ben Van Johnson

  3. #3
    Registered User
    Join Date
    08-15-2015
    Location
    Usa
    MS-Off Ver
    2013
    Posts
    12
    Text box take any date format and any other alfa numeric text without checking the date format.
    I can enter ‘2015/12/14’ or even I can enter ‘hello’ in text box and IF condition doesn’t work.

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

    Re: Date validation does not work on text box

    I would use 3 comboboxes to select Year, Month, Day, so that you don't need to worry about "validation"....

+ 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] VBA import text file dosnt work properly with date
    By beekobeeko in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-06-2020, 06:03 PM
  2. Data Validation Date or predefined text
    By MetteGaga in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-04-2018, 10:20 AM
  3. Data Validation Date or predefined text
    By MetteGaga in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-04-2018, 10:20 AM
  4. Data Validation - Need a date or specific text to be input
    By garethmckeeveraxa in forum Excel General
    Replies: 2
    Last Post: 04-25-2016, 05:54 AM
  5. Data Validation - Text and Any Date Entry
    By Follychops in forum Excel General
    Replies: 2
    Last Post: 06-02-2011, 04:07 AM
  6. Formatting from Text to Date ; doesnt work
    By babarorhum in forum Excel General
    Replies: 1
    Last Post: 09-18-2008, 10:50 AM
  7. Replies: 0
    Last Post: 01-18-2005, 06:48 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