Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
JT JT is offline
external usenet poster
 
Posts: 234
Default SetFocus issue

I'm using the code below to check the value a user has entered in a textbox
(TB10) when they move to the next textbox (TB11). It is checking the value
against a list of accounts on the "Macros" sheet.

The problem I am having is that the cursor moves to TB11 when "Proceed =
False" instead of to TB10. I want the cursor to move back to TB10 so the
user can try to enter a valid account again before moving on to the next
textbox. I thought TB10.SetFocus would do the trick but I can't get it to
work.

Any help in getting the cursor to TB10 would be greatly appreciated.

Private Sub TB10_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Cancel = False
TB10_LostFocus
Dim CheckThis As String
Dim Proceed As Boolean
CheckThis = ""
Proceed = False
CheckThis = TB10
If Len(CheckThis) < 4 Then
Do Until Len(CheckThis) = 4
CheckThis = "0" & CheckThis
Loop
End If

Dim r As Integer
r = 1

Do Until Len(Trim(Worksheets("Macros").Cells(r, 26))) = 0
If CheckThis = Worksheets("Macros").Cells(r, 26) Then
Proceed = True
End If
r = r + 1
Loop

If Proceed = False Then
TB10 = ""
TB10.SetFocus
Exit Sub
End If

End Sub
--

Thanks for the help........

JT
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 ranswrt Excel Programming 2 July 22nd 08 02:56 AM
SetFocus not working WLMPilot Excel Programming 4 February 15th 08 04:29 PM
SetFocus? plh Excel Programming 1 May 1st 06 03:01 AM
Form, SetFocus and AfterUpdate issue Piers 2k Excel Programming 2 November 8th 05 01:52 PM
setfocus Dean Reardon Excel Programming 2 December 15th 04 12:18 PM


All times are GMT +1. The time now is 06:18 AM.

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

About Us

"It's about Microsoft Excel"