Have any of you noticed or had problems with setting focus to a control with flexibility? I'll do a set focus on a control, and then take the value of that control only to error out saying 'A VBA Setfocus request could not be completed'. This happens quite a bit, for example the following code:
Private Sub LineNo_GotFocus()
TotalLineNumbers = LineNo.Text - 1
If MsgAnswer = 6 Then
For I = 1 To TotalLineNumbers
LineNo.Text = I
I = I + 1
SendKeys "{Tab}"
ReqDate.SetFocus
ReqDate.Text = NewReqDate
NewReqDate = ""
OldReqDate = ""
SendKeys "{Enter}"
Next
MsgAnswer = 0
I = 0
End If
End Sub
The only thing I can think of is because it's after the tab. How does VBA interpret this? The error comes on the ReqDate.text = NewReqDate
Private Sub LineNo_GotFocus()
TotalLineNumbers = LineNo.Text - 1
If MsgAnswer = 6 Then
For I = 1 To TotalLineNumbers
LineNo.Text = I
I = I + 1
SendKeys "{Tab}"
ReqDate.SetFocus
ReqDate.Text = NewReqDate
NewReqDate = ""
OldReqDate = ""
SendKeys "{Enter}"
Next
MsgAnswer = 0
I = 0
End If
End Sub
The only thing I can think of is because it's after the tab. How does VBA interpret this? The error comes on the ReqDate.text = NewReqDate