text boxes & Tab key

  • Thread starter Thread starter NetComm888
  • Start date Start date
N

NetComm888

I'm using the Excel spreadsheet to collect data. I know it's not the
best way to do it. But it's probably the only way I could do in my
work environment.
I added some text boxes on the spreadsheet, where the clients could
type in info like name, address etc. But the problem is when the
client finishes one box, he(she) couldn't use the "tab" key to jump to
the next box. Instead the client has to use the mouse to click the
next box. That could be annoying, if you need to type in many boxes.
I know Access could do solve the problem. But Is there anyway Excel
could handle this?
Many thanks
 
Instead of using text boxes, you can use cells. Unlock the cells in
which the clients should enter data (Format>Cells>Protection).

Then, protect the worksheet (Tools>Protection>Protect Sheet)
The users can press the Tab key to move from one unprotected cell to the
next.
 
Thanks alot for your suggestion.
But the problem is each text box is linked to another spreadsheet
which collects all those entered data. If I used "cell", then I have
to copy all the cells into that spreadsheet. That could be time
consuming. So it seems like i'm stuck with text boxes in this project.
If TAB key cann't jump among those text boxes, is there anyway I could
use a macro code to reserve a key for the jump?
thanks
 
If these are textboxes from the Controls Toolbox, you could trap their
KeyDown events e.g. this simple code for two textboxes:

Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger,
ByVal Shift As Integer)
If KeyCode = vbKeyTab Then
TextBox2.Activate
End If
End Sub

Private Sub TextBox2_KeyDown(ByVal KeyCode As MSForms.ReturnInteger,
ByVal Shift As Integer)
If KeyCode = vbKeyTab Then
TextBox1.Activate
End If
End Sub

However, this approach doesn't scale well so you should create an
array or collection and maintain your own tab index i.e. based on the
textbox which raised the event, you know which to activate next.
 
Back
Top