Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Hisham Younis   on Nov 24 In MS Office Category.

  
Question Answered By: Constance Reid   on Nov 24

I think I've found a solution based on some closer investigation
outlined below. The solution which first came to mind and worked was
to have a flag (which I set up at the top of the userform's code
module) that was used to set the focus  back to the text  box if the
flag was set in the first location I found setfocus  not to be ignored
by Excel. So this is what became of code  (and it should work
with more than 2 controls on the form):


Dim Wrong As Boolean 'the flag

Private Sub txtStringLineInput_KeyDown(ByVal KeyCode As
MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 13 Then
Wrong = True
Me.lstStringSetData.AddItem Me.txtStringLineInput.Text
Me.txtStringLineInput.Text = ""
End If
End Sub

Private Sub lstStringSetData_Enter()
If Wrong Then
Me.txtStringLineInput.SetFocus
Wrong = False
End If
End Sub

Share: 

 

This Question has 20 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on 2003 - Setfocus on userform Or get search suggestion and latest updates.


Tagged: