Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Keeping focus on a txtbox

I have a form with 2 controls; TextBox1 and SpinButton1. I want only
TextBox1 to ever have focus, and for SpinButton1 to do a small job,
then give focus back to TextBox1. The code I have written is as
follows:

Option Explicit
Private Sub SpinButton1_SpinDown()
TextBox1.SetFocus
End Sub
Private Sub SpinButton1_SpinUp()
TextBox1.SetFocus
End Sub

When I click SpinButton1, focus is sent to TextBox1 only every other
time; not every time. However, when I put a breakpoint on
TextBox1.SetFocus (so I have to click the 'run' arrow each time), focus
is returned to TextBox1 each time as it should be. Although tabstop
does not affect this effect, I do have it set to false. Setting
TakeFocusOnClick to false isn't a help, because a spin button doesn't
have that property, so I can't set it at all. I have placed a
'doevents' statement in each Sub, but that didn't help (Perhaps I
didn't do it correctly?).

How can I get it to return focus after each click to TextBox1?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Keeping focus on a txtbox


heres the reply from your other thread. it's the same thing to be
done.

I dont have much experience with spinbuttons, but just as a little fun,
I tried to goof around with it. It's probably not 100% correct as far as
correct programming format, but it gets the job done, at least on my
system.

Add a SpinButton1.SetFocus command before the TextBox1.SetFocus
command. When you click on it, it doesnt depress like normal, but it
does reset the focus after only 1 click each time.

Option Explicit
Private Sub SpinButton1_SpinDown()
SpinButton1.SetFocus
TextBox1.SetFocus
End Sub
Private Sub SpinButton1_SpinUp()
SpinButton1.SetFocus
TextBox1.SetFocus
End Sub


--
dok112
------------------------------------------------------------------------
dok112's Profile: http://www.excelforum.com/member.php...o&userid=10581
View this thread: http://www.excelforum.com/showthread...hreadid=531110

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
Keeping focus on a txtbox Tim[_44_] Excel Programming 4 April 6th 06 04:54 PM
Keeping The Focus From Changing. How? abxy[_74_] Excel Programming 9 August 31st 05 09:08 PM
txtbox problem [email protected] Excel Programming 0 May 18th 05 05:11 PM
To put value from txtbox to cell? Samick Excel Programming 1 November 13th 04 10:57 AM
txtbox code Sal_sal Excel Programming 1 December 12th 03 11:25 AM


All times are GMT +1. The time now is 08:26 PM.

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"