Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to activate text box in XP 1

Status
Not open for further replies.

hegartyjp

Programmer
Jun 16, 2004
57
US
I have a number of text boxes on a form in Excel 2000 that I need to be able to tab between. I have used the textbox.select followed by textbox.activate which worked OK in Excel 97 but in Excel 2000 I keep getting the following error message

The instruction at 0x60010b06 refernced memory at 0x0000003e. The memory could not be read.

Please help I have been doing this all day and I am going mad!!!!

Thanks.
 
Checkout VBA help for the TabIndex and TabStop properties for the controls and use them. These are designed to facilitate tabing between controls.

HTH Hugh
 
In general you will just need to set the TabIndex and TabStop properties for controls at design time but it is worth remembering that they can (in vb6 and I expect VBA too) be changed at runtime; the latter can be very handy if you have created controls at runtime. Hugh...
 
Thanks but I think you are refering to Acess - I am working in Excel and there is no tab index property!

Any other ideas.... please.
 
No Excel UserForm - TextBoxes, Command buttons, ListBoxes (I could go on) do have a TabIndex Property.

You originally posted <<I have a number of text boxes on a form >>
Did you mean a Sheet?

regards Hugh
 
Sorry - I did mean sheet not form.

Thanks I will change it and use a form instead.
 
In excel xp I have this working (controls toolbox, sheet's module):
Code:
Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = vbKeyTab Then
    Me.TextBox2.Activate
End If
End Sub

combo
 
Yeah I am also using that keydown function and checking for keycodes matching tab or enter.

It worked fine for NT.

Now though i get the error mentioned avove when the system hits the activate line.

I have

textbox2.select
textbox2.activate

the select works but this highlights the textbox and you would still need to click in the textbox to write in it.

If I take out the .activate line, it is ok.

But if I put it back in, it falls over.

Unfortunately I need to activate the textbox. It may possibly be libraries do you think?

Thanks for reply.

 
Do you need to activate or select the text box? In my configuration select+activate crashes excel.
Single 'select' causes selection of control, like for shapes. It is not possible to activate the control in this state.
'Activate' moves the edition cursor to the activated control. No need to use 'select' first. I guess that this is what you would like to get.

combo
 
BTW, KeyUp event seems to be more reasonable and behaves better. But still there is no reason to use 'Select' method.

combo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top