Textbox defaults

  • Thread starter Thread starter Confused
  • Start date Start date
C

Confused

I have a userform with 3 textboxes and a commandbutton
that acts as an enter botton. Textbox1 is for a target and
textboxes2 & 3 are for plus and minus tolerances. I am
working under the assumption that the tolerances are
balanced would like textbox3 to default to the textbox 2
value as soon as it is activated. Is this possible?
 
Maybe something like:

Option Explicit
Dim blkProc As Boolean
Private Sub TextBox3_Change()
If blkProc Then Exit Sub
'any code you have here
End Sub

Private Sub TextBox3_Enter()
If Me.TextBox2.Value <> "" _
And Me.TextBox3.Value = "" Then
blkProc = True
Me.TextBox3.Value = Me.TextBox2.Value
blkProc = False
End If
End Sub

The blkProc stuff acts like application.enableevents. Since we're changing the
value of textbox3 in code, we probably don't want the textbox3_change sub to
fire.

If you didn't have any textbox3_change code, you could dump the whole blkproc
stuff.
 
Back
Top