Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to comp.apps.spreadsheets,microsoft.public.excel,microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3
Default Focus

Hello,

I wonder if someone can help me with this: I'm trying to confirm a valid
time entry in a form field, and if invalid, clear the entry and put the
focus back in that field. If I use the following code it does work (not
the best method, no doubt), but if I remove the UserForm1.Hide and
UserForm1.Show lines, the focus always moves to the next field. I know I'm
missing something basic here, not sure what. Thanks,

Dave

If Private Sub txtTime1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
On Error GoTo BadTime
Dim X
txtTime1.Text = Format(Val(txtTime1.Text), "00:00")
X = TimeValue(txtTime1.Text)
Exit Sub
BadTime:
UserForm1.Hide
MsgBox ("Invalid time")
txtTime1.Text = ""
txtTime1.SetFocus
UserForm1.Show
End Sub


 
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
focus Capp Excel Discussion (Misc queries) 2 November 18th 05 07:25 PM
set focus tkaplan Excel Discussion (Misc queries) 3 September 27th 05 07:41 PM
RTD Getting The Focus James Dunkerley Excel Programming 1 December 2nd 04 06:57 PM
focus Art[_6_] Excel Programming 1 June 7th 04 05:53 PM
focus? Chrome[_3_] Excel Programming 3 May 13th 04 10:01 PM


All times are GMT +1. The time now is 10:22 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"