J
justinclose
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!
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!