hypuk
10-14-2009, 11:09 AM
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
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