#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 93
Default exit event

I have a form that has two text boxes that are initiated as follows::

Dim Tm As Date
Tm =
Evaluate("=IF(MINUTE(TIME(HOUR(Now()),MINUTE(Now() ),0))-MINUTE(TIME(HOUR(Now()),FLOOR(MINUTE(Now()),15),0) )<8,TIME(HOUR(Now()),FLOOR(MINUTE(Now()),15),0),TI ME(HOUR(Now()),CEILING(MINUTE(Now()),15),0))")

txtStartDate.Text = Format(Date, "mm/dd/yy")
txtStartTime.Text = Format(Tm, "h:mm AM/PM")

If I tab into the StartDate text box and type "1/22" (without the
quotes, of course) and then tab to the next field, the following
procedure runs:

Private Sub txtStartDate_exit(ByVal cancel As MSForms.ReturnBoolean)
txtStartDate.Value = Format(txtStartDate, "mm/dd/yy")
End Sub

and the text in the StartDate box changes to "01/22/06".

But if I type "8 a" in the StartTime box and then tab out of it, it
doesn't reformat even though there is a similar procedure for it

Private Sub txtStartTime_exit(ByVal cancel As MSForms.ReturnBoolean)
txtStartTime.Text = Format(txtStartTime, "h:mm AM/PM")
End Sub

When all data is entered in the form and other procedures are run, the
"8 a" is read and calculated correctly so there is no functional
problem. I would just like it to reformat it's appearance to reassure
users that they have entered what they intended. Does anyone know how
to fix this?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default exit event

Option Explicit
Private Sub txtStartTime_Exit(ByVal Cancel As MSForms.ReturnBoolean)
txtStartTime.Text = Format(txtStartTime.Text, "H:MM AM/PM")
End Sub
Private Sub UserForm_Initialize()
txtStartTime.Text = Format(Now, "H:MM AM/PM")
End Sub


"John Pierce" wrote:

I have a form that has two text boxes that are initiated as follows::

Dim Tm As Date
Tm =
Evaluate("=IF(MINUTE(TIME(HOUR(Now()),MINUTE(Now() ),0))-MINUTE(TIME(HOUR(Now()),FLOOR(MINUTE(Now()),15),0) )<8,TIME(HOUR(Now()),FLOOR(MINUTE(Now()),15),0),TI ME(HOUR(Now()),CEILING(MINUTE(Now()),15),0))")

txtStartDate.Text = Format(Date, "mm/dd/yy")
txtStartTime.Text = Format(Tm, "h:mm AM/PM")

If I tab into the StartDate text box and type "1/22" (without the
quotes, of course) and then tab to the next field, the following
procedure runs:

Private Sub txtStartDate_exit(ByVal cancel As MSForms.ReturnBoolean)
txtStartDate.Value = Format(txtStartDate, "mm/dd/yy")
End Sub

and the text in the StartDate box changes to "01/22/06".

But if I type "8 a" in the StartTime box and then tab out of it, it
doesn't reformat even though there is a similar procedure for it

Private Sub txtStartTime_exit(ByVal cancel As MSForms.ReturnBoolean)
txtStartTime.Text = Format(txtStartTime, "h:mm AM/PM")
End Sub

When all data is entered in the form and other procedures are run, the
"8 a" is read and calculated correctly so there is no functional
problem. I would just like it to reformat it's appearance to reassure
users that they have entered what they intended. Does anyone know how
to fix this?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 93
Default exit event

Patrick, have you tested your suggestion? Does it work for you? I have
tried to use it in my application but it doesn't make any difference.
Thanks
John

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 93
Default exit event

With reference to the first post in this thread: What I didn't mention
in the description of the situation, because I had no Idea it was
significant, is that the two text boxes - StartDate and StartTime - are
inside of a frame, aka group box. This makes all the difference in the
world. If I change the tab order of the two text boxes, the StartTime
one will update on exit and the StartDate one won't. However, in either
situation, exiting whichever textbox won't update correctly in the
opposite direction, that is, with a shift+tab, will update it. So now
does anyone have a solution to this?

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
Need some help with Exit Event Matt[_31_] Excel Programming 4 April 1st 05 12:22 AM
Form Exit Event JT[_2_] Excel Programming 1 September 17th 04 02:29 AM
combobox exit event Dave D[_3_] Excel Programming 0 April 28th 04 10:22 PM
Exit Event Michael J. Malinsky Excel Programming 1 February 27th 04 06:40 PM
Control Exit event Fred Excel Programming 0 November 19th 03 12:59 AM


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