textbox disappears using textbox.activate

D

dan dungan

Hi,

Using Excel 2000 on Windows 2000 Professional,

I'm using the following code to tab to the next textbox on a
worksheet. When I exit the design mode and press tab in the textbox,
the destination textbox disappears. The cursor is there but I can't
see it. Is there any way to keep the cursor visible?

Thanks,

Dan

Private Sub TextBox3_KeyDown(ByVal KeyCode As MSForms.ReturnInteger,
ByVal Shift As Integer)
''' Check if the TAB or ENTER key was pressed.
If KeyCode = vbKeyTab Or KeyCode = vbKeyReturn Then
''' If this is Excel 97 you must select a cell
''' before attempting to activate another control.
If Val(Application.Version) < 9 Then
Me.Range("A1").Select
End If
''' Move the focus appropriately.
If CBool(Shift And 1) Then
''' The user was holding down the SHIFT key
''' move back to the previous control.
TextBox3.Activate

Else
''' Move to the next control.
TextBox4.Activate

End If
End If
End Sub
 
D

dan dungan

Hi JLGWhiz,

Thanks for your response.

These textboxes are not on a userform; I placed them directly on the
worksheet.

But I think I've discovered a solution:

I changed the BorderStyle property from fmBorderStyleNone to
fmBorderStyleSingle and the cursor does not disappear, so far.

Thanks,

Dan
 
D

dan dungan

This ''solution" didn't work for the end users. I'm developing an .xlt
file. The end users use a copy of the template.

When they tab or enter to go to the next textbox or combobox on the
worksheet, the object seems to get the focus but the end user can not
see it on the worksheet. If the user starts typing the object is
updated.

Has anyone else seen this type of behavior?

Can anyone recommend a way to keep the objects visible when receiving
the focus? I don't know how to test if the object actually has the
focus. All I know is if you start typing the object shows the text
just typed.

I'm using textboxes because I need to populate one of them with the an
sql statement and I wanted to reduce keystrokes and mouseclicks for
the end user.

I'm unable to generate consistent results. Sometimes the object
"disappears". Sometimes it has diagonal lines through it--at least you
can see it--and sometimes the object looks normal with the cursor
flashing and ready to accept data. Sometimes when I click the mouse
in the object--the cursor isn't shown--I have to click again to get
the cursor to show.

Here's a sample of code I'm using:

Private Sub ComboBox2_KeyDown(ByVal KeyCode As MSForms.ReturnInteger,
ByVal Shift As Integer)
''' Check if the TAB or ENTER key was pressed.
If KeyCode = vbKeyTab Or KeyCode = vbKeyReturn Then
''' If this is Excel 97 you must select a cell
''' before attempting to activate another control.
If Val(Application.Version) < 9 Then
Me.Range("A1").Select
End If
''' Move the focus appropriately.
If CBool(Shift And 1) Then
''' The user was holding down the SHIFT key
''' move back to the previous control.
TextBox2.Activate
Else
''' Move to the next control.
TextBox4.Activate
Application.Calculate
End If
End If
End Sub
 

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