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: 343
Default Reselect a TextBox

Below is my AfterUpdate code for TextBox12. Part of that code gives me a
message if an incorrect time is entered (like 2845 instead of 1845). Is
there any code that I can place after the MsgBox so that the number in
TextBox12 will be selected. My goal is to prevent them from moving on until
the correct number is entered.




Private Sub TextBox12_AfterUpdate()

On Error GoTo error


TextBox12.Value = Format(Application.Text(Replace(TextBox12.Value, ":",
""), "00\:00"), "hh:mm")

If TextBox12.Value "" Then
If TextBox11.Value "" Then

TextBox13.Value = (TimeValue(TextBox12.Value) -
TimeValue(TextBox11.Value)) * 24
TextBox13.Value = Format(TextBox13.Value, "0.0000")

TextBox1.Value = CDbl("0" & TextBox13.Value) + CDbl("0" &
TextBox23.Value) + CDbl("0" & TextBox33.Value) + CDbl("0" & TextBox43.Value)
+ CDbl("0" & TextBox53.Value) + CDbl("0" & TextBox63.Value) + CDbl("0" &
TextBox14.Value) + CDbl("0" & TextBox24.Value) + CDbl("0" & TextBox34.Value)
+ CDbl("0" & TextBox44.Value) + CDbl("0" & TextBox54.Value) + CDbl("0" &
TextBox64.Value)
TextBox1.Text = Format(TextBox1.Text, "0.0000")
End If
End If

'Test that to see if hours worked exceeds shift length

If TextBox12.Value "" Then
If TextBox11.Value "" Then

TextBox2 = TextBox4 - TextBox1

End If

If TextBox2.Value < 0 Then
TextBox2.Value = 0
GoTo Finished
End If

TextBox2 = TextBox4 - TextBox1
TextBox2.Text = Format(TextBox2.Text, "0.0000")

End If

Finished:

If TextBox12.Value = "" Then
TextBox13.Value = ""
End If

If TextBox11.Value = "" Then
TextBox13.Value = ""
End If
End

error:
MsgBox "please enter only time values"

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
HELP! I Lost The Ability To Advance From TextBox To TextBox With the ENTER Or The TAB Keys Minitman[_4_] Excel Programming 0 February 22nd 05 08:50 PM
Textbox Bug? Missing/delayed update of textbox filled via VBA MarcM Excel Programming 0 November 4th 04 05:47 PM
Textbox Bug? Missing/delayed update of textbox filled via VBA MarcM Excel Programming 0 November 4th 04 05:43 PM
How to move cursor from one textbox control to another textbox con KMoore007 Excel Programming 0 September 16th 04 02:47 PM
Reselect cell after macro gman[_3_] Excel Programming 3 February 5th 04 07:01 PM


All times are GMT +1. The time now is 08:34 AM.

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"