Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.tables
JFR JFR is offline
external usenet poster
 
Posts: 1
Default how do i create a form so that a selected check box shows time

I would like to create a form to use for recording an ongoing series of
events. The form would have a check box that when checked would display
current time (start of event). Another check box when checked would also
display the current time (end of event). Finally the elapsed time
(difference between start and end of event would be displayed.

Thanx
  #2   Report Post  
Posted to microsoft.public.word.tables
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default how do i create a form so that a selected check box shows time

I would create a userform with two checkboxes chkStart and chkEnd, three
textboxes txtStart, txtEnd and txtElapsed and a command button cmdClear

Then use the following code in the UserForm:

Private Sub chkEnd_Click()
Dim Hours As Long, Minutes As Long, Seconds As Long, Elapsed As Long
txtEnd.Text = Format(Now, "HH:mm:ss")
If chkEnd.Value = True Then
Elapsed = DateDiff("s", txtStart, txtEnd)
Else
Exit Sub
End If
Hours = Int(Elapsed / 3600)
Minutes = Int((Elapsed Mod 3600) / 60)
Seconds = Elapsed Mod 60
txtElapsed.Text = Format(Hours, "00") & ":" & Format(Minutes, "00") & ":" &
Format(Seconds, "00")
End Sub

Private Sub chkStart_Click()
txtStart.Text = Format(Now, "HH:mm:ss")
End Sub

Private Sub cmdClear_Click()
chkStart.Value = False
txtStart.Text = ""
chkEnd.Value = False
txtEnd.Text = ""
txtElapsed.Text = ""
End Sub

When you check the chkStart checkbox, the start time will be displayed in
the txtStart textbox as HH:mm:ss and when the chkEnd checkbox is checked,
the txtEnd textbox will display the finish time as HH:mm:ss and the
txtElapsed textbox will display the elapese time, also in HH:mm:ss format.

The cmdClear button will remove all data from the form so that the process
can be repeated.

If you don't know how to create a userform, see the necessary parts of the
article "How to create a Userform" at:

http://word.mvps.org/FAQs/Userforms/CreateAUserForm.htm

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"JFR" wrote in message
...
I would like to create a form to use for recording an ongoing series of
events. The form would have a check box that when checked would display
current time (start of event). Another check box when checked would also
display the current time (end of event). Finally the elapsed time
(difference between start and end of event would be displayed.

Thanx



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I check the spelling in only one of multiple form fields? Aldon Microsoft Word Help 10 August 25th 06 03:27 PM
Can I change the check style for the check box form field in '03? Mercury Microsoft Word Help 1 August 15th 06 11:29 PM
To create a form Broken man New Users 1 March 23rd 06 05:50 PM
How do I create a document with a check list but that others can . Barbara Wyman Microsoft Word Help 2 December 31st 04 09:12 PM
date and time check button problem jay Tables 0 December 13th 04 07:44 AM


All times are GMT +1. The time now is 02:24 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"