Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 237
Default SetFocus Problem

My original question was...What is the code to enter lets
say TextBox6. When I say this, I want the cursor to enter
that textbox.

Robin Hammond said to use setfocus

textbox6.setfocus

When I do this it does not work. The way I did it was
entering a value in textbox6 and clicking in another
textbox, if a certain condition is met a msgbox pops up
telling the user invalid value and then the next line is
textbox6.setfocus to bring the cursor back in that
textbox, but instead, the cursor goes to the textbox I
clicked.

How do I fix this?

Thank you

Todd Huttenstine
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default SetFocus Problem

Todd,

This works for me

With TextBox6
.SetFocus
.SelStart 1
.SelLength = Len(.Text)
Cancel = True
End With

I use this code in the Textbox Exit event, as this has the option to cancel
an exit.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Todd Huttenstine" wrote in message
...
My original question was...What is the code to enter lets
say TextBox6. When I say this, I want the cursor to enter
that textbox.

Robin Hammond said to use setfocus

textbox6.setfocus

When I do this it does not work. The way I did it was
entering a value in textbox6 and clicking in another
textbox, if a certain condition is met a msgbox pops up
telling the user invalid value and then the next line is
textbox6.setfocus to bring the cursor back in that
textbox, but instead, the cursor goes to the textbox I
clicked.

How do I fix this?

Thank you

Todd Huttenstine



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default SetFocus Problem

Thank you that did it.


-----Original Message-----
Todd,

This works for me

With TextBox6
.SetFocus
.SelStart 1
.SelLength = Len(.Text)
Cancel = True
End With

I use this code in the Textbox Exit event, as this has

the option to cancel
an exit.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Todd Huttenstine"

wrote in message
...
My original question was...What is the code to enter

lets
say TextBox6. When I say this, I want the cursor to

enter
that textbox.

Robin Hammond said to use setfocus

textbox6.setfocus

When I do this it does not work. The way I did it was
entering a value in textbox6 and clicking in another
textbox, if a certain condition is met a msgbox pops up
telling the user invalid value and then the next line is
textbox6.setfocus to bring the cursor back in that
textbox, but instead, the cursor goes to the textbox I
clicked.

How do I fix this?

Thank you

Todd Huttenstine



.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
SetFocus using variable name Taras Excel Programming 2 December 4th 03 10:11 PM
SetFocus Problems Zane Greer Excel Programming 1 September 20th 03 02:26 PM
TextBox SetFocus Problem Tom Ogilvy Excel Programming 1 September 12th 03 01:27 PM
SetFocus problem RFraley Excel Programming 2 September 7th 03 01:18 PM
TextBox.SetFocus steve Excel Programming 4 July 16th 03 07:40 PM


All times are GMT +1. The time now is 05:13 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"