Consulting

Results 1 to 7 of 7

Thread: textbox validation help please :-)

  1. #1

    textbox validation help please :-)

    Hi there

    I have two sets of nine text boxes, all with validation on them, basicaly a minimum and maximum character length, but I'm not going to have to fill all two sets of nine boxes in all of the time, how can I de activate the boxes that are not needed at the time? Could I use a tick box and tick the ones I want to activate?

    Below is my code for the text boxes, any help would be much appreciated, I'm new to VBA too.

    Thanks
    Mark

    Private Sub MultiPage1_Change()
    If Len(cc1.Text) < 6 Then
        MsgBox "A minimum of 6 characters is needed for the Cost Centre"  'Your error raise code goes here
    End If
    If Len(pi1.Text) < 7 Then
        MsgBox "A minimum of 7 numbers is needed for the PI Number"  'Your error raise code goes here
    End If
    If Len(cc2.Text) < 6 Then
        MsgBox "A minimum of 6 characters is needed for the Cost Centre"  'Your error raise code goes here
    End If
    If Len(pi2.Text) < 7 Then
        MsgBox "A minimum of 7 numbers is needed for the PI Number"  'Your error raise code goes here
    End If
    If Len(cc3.Text) < 6 Then
        MsgBox "A minimum of 6 characters is needed for the Cost Centre"  'Your error raise code goes here
    End If
    If Len(pi3.Text) < 7 Then
        MsgBox "A minimum of 7 numbers is needed for the PI Number"  'Your error raise code goes here
    End If
    If Len(cc4.Text) < 6 Then
        MsgBox "A minimum of 6 characters is needed for the Cost Centre"  'Your error raise code goes here
    End If
    If Len(pi4.Text) < 7 Then
        MsgBox "A minimum of 7 numbers is needed for the PI Number"  'Your error raise code goes here
    End If
    If Len(cc5.Text) < 6 Then
        MsgBox "A minimum of 6 characters is needed for the Cost Centre"  'Your error raise code goes here
    End If
    If Len(pi5.Text) < 7 Then
        MsgBox "A minimum of 7 numbers is needed for the PI Number"  'Your error raise code goes here
    End If
    If Len(cc6.Text) < 6 Then
        MsgBox "A minimum of 6 characters is needed for the Cost Centre"  'Your error raise code goes here
    End If
    If Len(pi6.Text) < 7 Then
        MsgBox "A minimum of 7 numbers is needed for the PI Number"  'Your error raise code goes here
    End If
    If Len(cc7.Text) < 6 Then
        MsgBox "A minimum of 6 characters is needed for the Cost Centre"  'Your error raise code goes here
    End If
    If Len(pi7.Text) < 7 Then
        MsgBox "A minimum of 7 numbers is needed for the PI Number"  'Your error raise code goes here
    End If
    If Len(cc8.Text) < 6 Then
        MsgBox "A minimum of 6 characters is needed for the Cost Centre"  'Your error raise code goes here
    End If
    If Len(pi8.Text) < 7 Then
        MsgBox "A minimum of 7 numbers is needed for the PI Number"  'Your error raise code goes here
    End If
    If Len(cc9.Text) < 6 Then
        MsgBox "A minimum of 6 characters is needed for the Cost Centre"  'Your error raise code goes here
    End If
    If Len(pi9.Text) < 7 Then
        MsgBox "A minimum of 7 numbers is needed for the PI Number"  'Your error raise code goes here
    End If
    
    End Sub

  2. #2
    Moderator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,198
    Location
    Maybe something like this

    Hope this helps
    Last edited by georgiboy; 10-14-2009 at 09:59 PM.
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved
    Click here for a guide on how to upload a file with your post

    Excel 365, Version 2403, Build 17425.20146

  3. #3
    Hi georgiboy

    That's fantastic!!!

    Thanks for your help

    Mark

  4. #4
    Any ideas on how I reverse this?

    I.E I want the text boxes already populated and the checkboxes already ticked, and when I uncheck the checkboxes the text already populated in the textboxes dissapear?

    Thanks
    Mark

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    You don't deserve to get people helping you. You waste our time by re-posting the same question, cross-posting without linking. We are not all just here for your free support!
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  6. #6
    I appreciate everyone's support, but as far as I'm aware these are 2 seperate forums, where probably not eveyone is a member of both forums

  7. #7
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    It is irrelevant whether we are memberfs of both or not. You could have tow (or more) people working on the same problem at the same time, not knowing others are working on it. Worse, it might be solved elsewhere but another person may be unknowingly still working on it.

    Personally, I will not waste my time helping cross-posters, whether they link or not, they are wasting my time, and I can help more deserving cases. When I see cross-posting, I will warn others so that they will know.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •