+ Reply to Thread
Results 1 to 9 of 9

Restrict textbox entries to numbers

  1. #1
    Registered User
    Join Date
    11-22-2012
    Location
    United States
    MS-Off Ver
    Office 2013
    Posts
    25

    Restrict textbox entries to numbers

    Hi All,

    Limited to one textbox, how do I make it so that only numbers can be entered?

    Additionally, I'd like to add another restriction where the number entered must be less than the value of another textbox.

    Thanks so much for the help!

  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: Restrict textbox entries to numbers

    Perhaps.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    11-22-2012
    Location
    United States
    MS-Off Ver
    Office 2013
    Posts
    25

    Re: Restrict textbox entries to numbers

    Norie,

    Thank you! They both worked like a charm!

    A follow up question which might be a bit tougher. I have 3 combo boxes with dropdowns to select the date. Is there a way to write a similar restriction code so that the concatenated value of the three combo boxes is greater than today's date (which is listed in another textbox if that helps)?

    I tried this but it didn't function correctly:
    Please Login or Register  to view this content.
    Please note that the code for the date textbox is:
    Please Login or Register  to view this content.
    Thank you for the help, it's great.

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

    Re: Restrict textbox entries to numbers

    What's in the month combo?

  5. #5
    Registered User
    Join Date
    11-22-2012
    Location
    United States
    MS-Off Ver
    Office 2013
    Posts
    25

    Re: Restrict textbox entries to numbers

    In the userform, there are three comboboxes in a line. Each one has a dropdown list. The first has numbers for days of the month, the second lists the months, and third lists a 20 year range.

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

    Re: Restrict textbox entries to numbers

    Try this.

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    11-22-2012
    Location
    United States
    MS-Off Ver
    Office 2013
    Posts
    25

    Re: Restrict textbox entries to numbers

    Perfect! Thank you very much Norie

  8. #8
    Registered User
    Join Date
    11-22-2012
    Location
    United States
    MS-Off Ver
    Office 2013
    Posts
    25

    Re: Restrict textbox entries to numbers

    Hi again,

    After doing some further testing, the date restriction isn't working. In the form below (as less than today), it accepts any date:

    Please Login or Register  to view this content.
    When it appears as greater than today:
    Please Login or Register  to view this content.
    then it won't accept any date.

    Thanks for the help.

  9. #9
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    Why have you used Val?

    That's probably only going to return the first part of the date.

    That will be month or date, or even year, depending on the format of the date in the textbox.

    Try using CDate or DateValue instead.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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