Run Time Error 2185:

  • Thread starter Thread starter tsluu
  • Start date Start date
T

tsluu

I cant reference a property or method for a control unless the control has
the focus.

This error is triggered by the Change event when I reference .text property:

private Sub tbxStart_Change
If Not Trim(tbxTimes.Text & "") = "" And Not Trim(tbxStart.Text & "") =
"" Then
tbxEnd = tbxStart + tbxTimes
End If
end sub

I need the .text as the .value is different not an up to date figure. Is
there a work around.
 
tsluu said:
I cant reference a property or method for a control unless the control has
the focus.

This error is triggered by the Change event when I reference .text
property:

private Sub tbxStart_Change
If Not Trim(tbxTimes.Text & "") = "" And Not Trim(tbxStart.Text & "") =
"" Then
tbxEnd = tbxStart + tbxTimes
End If
end sub

I need the .text as the .value is different not an up to date figure. Is
there a work around.


In the Change event for tbxStart, you can refer to its .Text property -- no
problem there, because tbxStart has the focus. But you can't refer to the
..Text property of tbxTimes in that event, because tbxTimes doesn't have the
focus. However, at that point, the value of tbxTimes should be up to date,
so use its .Value property instead:

If Not Trim(tbxTimes & "") = "" _
And Not Trim(tbxStart.Text & "") = "" _
Then
tbxEnd = tbxStart + tbxTimes
End If

Or maybe that assignment should be:

tbxEnd = tbxStart.Text + tbxTimes

.... depending on what you're trying to do.
 
Back
Top