+ Reply to Thread
Results 1 to 5 of 5

Validating textboxes

  1. #1
    Forum Contributor
    Join Date
    12-14-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    106

    Validating textboxes

    Hi I have various text boxes. On initialisation one is blank no2 is "00" and no. 3 is "00"

    I am looking for a way to validate that an entry has been made in each textbox and that it is numeric. And if no entry is made then populate msgbox stating to make entry and refocus on the textbox.

    currently I have
    Please Login or Register  to view this content.
    im not sure if this is the correct way to validate or if this is simply a poor workaround Any thoughts much appreciated.

  2. #2
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Validating textboxes

    Hi there,

    Take a look at the attached workbook and see if it does what you need. You'll obviously need to customise the text used in the labels on the form and the associated constant values used in the mbDataValidationIsOk function.

    The VBA code uses some items which are definitely not "Beginner-Level" techniques, but are useful in providing a helpful user interface. Let me know if you need further information about the code.

    Hope this helps - please let me know how you get on.

    Regards,

    Greg M
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    01-02-2007
    Location
    Australia NSW
    MS-Off Ver
    2013
    Posts
    494

    Re: Validating textboxes

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    12-14-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    106

    Re: Validating textboxes

    Quote Originally Posted by Greg M View Post
    Hi there,

    Take a look at the attached workbook and see if it does what you need. You'll obviously need to customise the text used in the labels on the form and the associated constant values used in the mbDataValidationIsOk function.

    The VBA code uses some items which are definitely not "Beginner-Level" techniques, but are useful in providing a helpful user interface. Let me know if you need further information about the code.

    Hope this helps - please let me know how you get on.

    Regards,

    Greg M
    Many thanks for this Greg. Just the kind of thing I was after. As you say its perhaps not for beginner level but when I get to work tomorrow I will try and work through it all to see if I understand it all and will post back with any queries regarding the code.

    Thanks again.

    ps. can this validation approach also be applied to textboxes formatted as dates. For example if left empty or if date is in the future or not this year?

  5. #5
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Validating textboxes

    Hi again,

    Thanks for your reply - it's nice to know that we're at least heading in the right direction

    Regarding validation of Date values, it's certainly possible to expand the mbDataValidationIsOk function to accommodate checks for valid date values (use the IsDate function). You'll probably need to add a sDATE constant (with a value of "date ") so that you can generate a prompt message saying "You have not entered a date value for Data x".

    Let me know if you need any further information.

    Regards,

    Greg M

+ 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. Validating A Price
    By migg in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-14-2008, 12:20 PM
  2. Validating with VBA
    By Sirishgreen in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-21-2007, 06:26 AM
  3. validating
    By Ayesha in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-26-2006, 10:00 AM
  4. Validating
    By Sdbenn90 in forum Excel General
    Replies: 0
    Last Post: 03-26-2006, 07:10 PM
  5. Validating in VBA
    By Casey C in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-25-2005, 04:25 PM

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