UserForm - Navigating fields when changing visibie property

  • Thread starter Thread starter Rob W
  • Start date Start date
R

Rob W

Greetings,

This is quite complex to explain but here goes, below is a mock up of my
user form:-

Label Title <Value> *Populated from result of combo box1
Combo Box 1 <Value select>
Text Box <Value = 'Todays date"> *Populated from result of combo box1
Combo Box 2 <Value select>

The form is launched and ONLY Combo Box 1 is set to visible (others on
intilisation of form have visible set to FALSE)

The user selects a value in Combo box 1 and label and text box are populated
and Combo box 1 is then set to disabled (ENABLED = FALSE).
The user can either change the Date value in the text box or press ENTER/TAB
etc.., to leave the text box ...

However the code behind Text Box_Exit event sets Combo Box 2 to visible.
VBA knows though whilst in the Text Box there is no where else on the form
to go, no other control are visible at that point so TAB/ENTER become
invalid options as they result in no action??

Other than adding an EXTRA button to validate the text (i.e. User is saying
I have finished my edit) can I make the Combo Box 2 appear somehow?

Hope this makes sense.
Rob W
 
If I understand correctly, you could use code like the following

Private Sub TextBox1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal
Shift As Integer)
If KeyCode = vbKeyTab Then
With Me.ComboBox2
.Visible = True
.SetFocus
.SelLength = Len(.Text)
.SelStart = 0
If .ListCount > 0 Then
.ListIndex = 0
End If
End With
KeyCode = 0
End If
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)
 
Thanks very much, worked a treat.

When I get a free minute I will look up the commands Im unfamilar with.

Thanks
Rob
 
Back
Top