+ Reply to Thread
Results 1 to 4 of 4

Prevent past date in userform textbox

  1. #1
    Registered User
    Join Date
    12-08-2013
    Location
    Dubai, United Arab Emirates
    MS-Off Ver
    Excel 2010
    Posts
    70

    Prevent past date in userform textbox

    Hi,

    Need some help please if possible. I have a userform with a date field in textbox. I also have a calculator form that was created separately and pops-up on the textbox enter event. What I want is when a user selects the date from the pop-up calculator, the exit evening of the textbox should check if the date is less than current date and display messagebox saying something. I have the following code but the problem is throws the error msgbox for any date which is less than 30! e.g current date is 23th of March, but when im selecting 27th of March it still is throwing the error. tried changing the code several ways up and down but guess im missing on something vital.

    Can someone be kind enough to look at this and correct the error.

    thanks a bunch in advance

    Please Login or Register  to view this content.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Prevent past date in userform textbox

    You need to convert the text date from the 'calculator' form to a 'real' date.

    That can be done using DateValue or CDate.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    12-08-2013
    Location
    Dubai, United Arab Emirates
    MS-Off Ver
    Excel 2010
    Posts
    70

    Re: Prevent past date in userform textbox

    the ddate variable is declared at date

  4. #4
    Registered User
    Join Date
    12-08-2013
    Location
    Dubai, United Arab Emirates
    MS-Off Ver
    Excel 2010
    Posts
    70

    Re: Prevent past date in userform textbox

    OMG!! THANKS A TRILLION. Norie

    I knew I was missing something very vital.

    ur a star!

+ 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] Excel 2007, Userform Textbox Date Format and Calendar Control Userform
    By riffology in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-03-2014, 06:18 PM
  2. Excel 2007: Userform Textbox Prevent Number as the first entry
    By Hudas in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-20-2012, 02:48 PM
  3. Date Format for textbox in userform
    By processchip in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-08-2011, 06:42 AM
  4. save file as name and date from an TextBox USERFORM
    By tullemann in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-17-2011, 11:55 AM
  5. Entering a date into a userform textbox
    By jerseyguy1996 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-01-2010, 12:28 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