+ Reply to Thread
Results 1 to 2 of 2

Validating Textboxes in UserFrom

  1. #1
    Forum Contributor
    Join Date
    05-08-2009
    Location
    england
    MS-Off Ver
    Excel 2007
    Posts
    223

    Validating Textboxes in UserFrom

    Before I start...this has been cross posted, as shown below...there just seems to be so few people that seem to use Word vba...

    http://www.vbaexpress.com/forum/show...es-in-UserFrom

    The question is as follows...

    In the attached example, the user must select an option through 2 checkboxes, be it “yes” or “no” which is associated to a textbox.

    The selection may or may not dicatate that the user ‘ough’t to make an entry in the textbox in order to provide some justification for their selection.

    What I need is some code to allow for the following to happen…

    If the user clicks on the submit button after selecting “yes” and then leaves the associated textbox empty, they will be issued with a msgbox prompt highlighting the fact that they haven’t made an entry into the textbox and inviting them to do so.

    The user can of course then choose whether to carry on without making an entry OR the code will force an exit from the process and direct them to the relevant textbox in order to make the entry.

    The user would then click submit again and the code would search for the next empty textbox where it ‘believes’ an entry should be made…..and so it would continue until all textboxes have been checked.

    The code I have already involves entering a Tag property to the textboxes and the code highlights them ALL in turn using a generic message. When the user identifies that a textbox is to be left blank and the checking process is to continue the code utilising the Tag property identifies the textbox that has already been checked and so will ignore it next time, rather than keep picking it up on one endless loop if it remains blank.

    The problem I have at the moment is that the code picks up ALL empty textboxes for validation rather than being dependant on the associated checkbox selection as a flag to validate an empty textbox, for example...

    In the first series...
    if "yes" is selected then the user should complete the associated textbox. If it's empty then it will get flagged.

    In the second series...
    If "no" is selected then the user should not complete the associated textbox. If it's empty then it will get ignored.

    in the third series...
    If "no" is selected then the user should complete the associated textbox. If it's empty then it will get flagged.

    and so on... the point is that I would need to specify in the code each possible combination and manually determine which ones get flagged, i.e.

    yes + empty - flag
    no + empty - flag
    yes + empty - ignore
    no + empty - ignore

    The code I have so far is as follows... can anyone help?

    Option Explicit
    Dim c As Collection

    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Validating Textboxes in UserFrom

    Is this solved?

    If you solve a problem yourself before anyone else has responded, please take a moment to describe your solution, chances are some other member will benefit.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ 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 textboxes
    By chrisjames25 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-06-2013, 11:58 AM
  2. Using userfrom to add a new row, column
    By SoCalRizzy in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-12-2008, 05:09 PM
  3. can you use the dtpicker in an userfrom
    By TerryR in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 10:05 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