Run Time Error 2185:

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.
 
D

Dirk Goldgar

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top