+ Reply to Thread
Results 1 to 5 of 5

Textbox Date Validation?

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    03-31-2012
    Location
    Hong Kong
    MS-Off Ver
    Excel 2010
    Posts
    140

    Textbox Date Validation?

    How to check the date_from.value validation before OKrun? where return to error:6 in case of input 20040825 on the textbox.

    Private Sub OKrun_Click()

    'Check date textbox
    If data_from.Value = Empty Or (Not IsDate(data_from.Value)) Or data_from.Value <> Format(data_from.Value, "yyyy/mm/dd") Then
    MsgBox "Please input data format as yyyy/mm/dd then OK。", vbCritical, "Input error"
    data_from.Value = Format(Range("A2").Value, "yyyy/mm/dd") 'default value
    GoTo reload_form
    End If
    ...
    Unload SettingForm
    reload_form:

    End sub

  2. #2
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Textbox Date Validation?

    try put it in textbox_afterupdate
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Forum Contributor
    Join Date
    03-31-2012
    Location
    Hong Kong
    MS-Off Ver
    Excel 2010
    Posts
    140

    Re: Textbox Date Validation?

    Quote Originally Posted by humdingaling View Post
    try put it in textbox_afterupdate
    how to solve error:6 overflow during input long number?
    input case format:
    2014/08/25 return TURE
    25/08/2014 return FALSE
    2014-08-25 return FALSE
    2014.08.25 return TRUE?
    2014/Aug/25 return FALSE
    20140825 return Error:6
    "" return FALSE
    "abc" return FALSE
    Last edited by alee001; 08-25-2014 at 11:57 AM. Reason: detail

  4. #4
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Textbox Date Validation?

    i think you need to rework your if loop
    though i dont know what you are working with...

    here is example of how it should react?

    if anything text is input into textbox it needs to be validated as a date first
    be careful though now if you have month and day back to front it would still pass

    ie 2nd of mar and 3rd of feb
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    03-31-2012
    Location
    Hong Kong
    MS-Off Ver
    Excel 2010
    Posts
    140

    Re: Textbox Date Validation?

    Thanks for the reference, and I learned to use on Textbox_afterupdate.

+ 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. TextBox Validation on the Fly
    By magness in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 06-22-2013, 11:29 AM
  2. TextBox Date Validation
    By mccrimmon in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-22-2010, 12:14 PM
  3. Replies: 5
    Last Post: 11-18-2010, 05:37 PM
  4. Date validation in textbox
    By aman1234 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-24-2010, 12:17 PM
  5. textbox validation
    By aman1234 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-17-2009, 09:40 AM

Tags for this Thread

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