ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,832
- Office Version
- 2007
- Platform
- Windows
I have a userform where one of my Comboboxes must allow either of the following.
N/A from drop down selection or a 17 character value.
The user should be able to select N/A from the drop down & move on but at present the code sees it as not 17 characters so keeps popping up the Msgbox & even when i try to close the form the Msg keeps popping etc but after a while it does close.
If the user doesnt select the N/A then they must enter a 17 character value, Example JHMDG12345TE210258
Code currently in use for ComboBox9 BUT think possibly a new version is needed for it to work correctly
Thanks
N/A from drop down selection or a 17 character value.
The user should be able to select N/A from the drop down & move on but at present the code sees it as not 17 characters so keeps popping up the Msgbox & even when i try to close the form the Msg keeps popping etc but after a while it does close.
If the user doesnt select the N/A then they must enter a 17 character value, Example JHMDG12345TE210258
Code currently in use for ComboBox9 BUT think possibly a new version is needed for it to work correctly
Thanks
VBA Code:
Private Sub ComboBox9_Change()
ComboBox9 = UCase(ComboBox9)
End Sub
Private Function ExitFunc() As Integer
If Len(Me.ComboBox9.Value) < 17 Then
MsgBox "VIN MUST BE 17 CHARACTERS IN LENGTH" & vbCr & vbCr & "CONTINUE TO EDIT THE VIN ?", vbYesNo + vbCritical
If vbYes Then
ComboBox9.SetFocus
Else
Unload McListForm
End If
End If
ComboBox9 = UCase(ComboBox9)
End Function
Private Sub ComboBox9_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Len(ComboBox9.Value) <> 17 Then
Cancel = True
MsgBox "VIN MUST BE 17 CHARACTERS IN LENGTH" & vbNewLine & vbNewLine & "PLEASE CHECK & TRY AGAIN", vbCritical, "VIN NUMBER LENGTH MESSAGE"
End If
End Sub