Hello, I have a userform with a mandatory textbox. Default value of this textbox is "ID". To force the user to enter an ID number in this textbox I'm using following code:
Private Sub TextBox102_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If HasContent(TextBox102) = False Or TextBox102.Value = "ID" Then
MsgBox ("ID mising !")
With Me.TextBox102
.Value = "ID"
.SetFocus
.SelStart = 0
.SelLength = Len(.Text)
End With
Cancel = True
Exit Sub
Else
GetData
End If
End Sub
This works well but has an unwanted consequence: if the user clicks the form's exit button, he's trapped into the textbox exit event. The only way to get out of this is CTRL+BREAK command.
Private Sub CommandButton108_Click() 'Exit UserForm
Unload Me
End Sub
Is there a workaround ? Thanks !
Bookmarks