+ Reply to Thread
Results 1 to 5 of 5

Data Validation in textbox on userform

  1. #1
    Forum Contributor
    Join Date
    02-10-2013
    Location
    Wolverhampton
    MS-Off Ver
    Excel 2010
    Posts
    101

    Data Validation in textbox on userform

    Hi, I have a userform where a user can enter a date in the textbox on the userform, and so the data is entered in the table once the user clicks OK on the userform. I am just wondering is there a VBA code which can limit the user to only entering the date in a format such as ##/##/####, in the following order ; day, month, and then year. If he/she enters a different format and clicks on OK on the userform to enter, then can a message box pop up warning the user that the data should be entered in proper format.

    So far, I have constructed the following If statement )see below), but it is not working, can anyone please help me?

    If Trim(Me.TextBox_Order_Date.Value) <> "##/##/####" Then
    Me.TextBox_Order_Date.SetFocus
    MsgBox "Please enter date in proper format"

    Exit Sub

    End If

  2. #2
    Valued Forum Contributor
    Join Date
    02-12-2011
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    818

    Re: Data Validation in textbox on userform

    Hello nav505,

    Try this once.

    Please Login or Register  to view this content.
    Last edited by HSV; 03-12-2013 at 07:19 PM.
    Kind regards, Harry.

  3. #3
    Forum Contributor
    Join Date
    02-10-2013
    Location
    Wolverhampton
    MS-Off Ver
    Excel 2010
    Posts
    101

    Re: Data Validation in textbox on userform

    Hi Harry, it is working as the pop up error message shows when the OK button on the userform is clicked, but the only problem is the data is stilled added, in the table, I want the code to prevent the user from entering any of the data unless the data is entered in its proper format
    Last edited by nav505; 03-12-2013 at 07:53 PM.

  4. #4
    Valued Forum Contributor
    Join Date
    02-12-2011
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    818

    Re: Data Validation in textbox on userform

    Try with the red lines.
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    02-10-2013
    Location
    Wolverhampton
    MS-Off Ver
    Excel 2010
    Posts
    101

    Re: Data Validation in textbox on userform

    Thank you so much, that is brilliant

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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