LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default SetFocus not working as I would expect

I am having some trouble getting the SetFocus method to work the way
that I think it should (and the way that the help files seem to
indicate). Here is my code snippet:

-----------------------
Sub txtbxStartTime_AfterUpdate()
Dim numChkResult As Integer

If txtbxStartTime.Value = "" Then
Exit Sub
'Want to jump out of here if the value was changed, then
deleted. Don't need to operate on empty inputs.
End If

'Calling function and capturing return value
numChkResult = NumberCheck(0) '0 indicates it was Start Time
txtbox that made the call

If numChkResult = 1 Then '"1" return value
indicates a problem
MsgBox "There was a problem with data entered into the Start Time
box. Go back and try again."
txtbxStartTime.SetFocus
lblHoursWorkedCalc.Caption = "" 'clearing the box so there
aren't odd values in it if a box is empty or wrong
Exit Sub
End If

If Not IsEmpty(txtbxStartTime.Value) Then 'Don't want to
head into this if it is empty, gets me errors.
If optStartAM.Value = True Then
dtStartTime = CDate(txtbxStartTime.Value & " A")
End If

If optStartPM.Value = True Then
dtStartTime = Format(txtbxStartTime.Value & " P", "Hh:Nn AM/
PM") 'Building the actual TIME datatype
End If
End If

CalcHoursWorked 'Calling my little function

End Sub
-------------------------------

What happens is that the focus ends up on the next tab stop control
instead of back on the this control. Essentially, I am checking the
numbers entered into the box and I want to return focus back to that
text box if the numbers don't check out. (I am asking them to enter
in the time of day that they started work. It is a simple (well,
supposed to be simple) time card spreadsheet interface project. I am
requesting time started then time ended.)

I have tried the SetFocus in the called NUMBERCHECK function, but get
the same result. So I imagine that it is just a matter of having the
command in the correct event. This is the AFTER_UPDATE event. So it
is my guess that the action of tabbing out of this text box control,
or clicking on another control, gets the SetFocus property evaluated
after this event finishes running.

Can anyone offer advice on this?

Thanks!

 
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
xcel how expect grow by 1.56% over january sales formula Marquin New Users to Excel 2 October 25th 06 12:39 PM
Combine Multiple Sheets: Complie Error, Expect Array BEEJAY Excel Programming 2 September 25th 06 02:39 PM
SetFocus not working Henry T Excel Programming 1 September 15th 05 05:33 PM
Sheet(Array( Won't print as I expect it to [email protected] Excel Worksheet Functions 0 June 21st 05 11:34 AM
setfocus Dean Reardon Excel Programming 2 December 15th 04 12:18 PM


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