Freeze time on a form.

G

Guest

I have a form that I'd like to use to measure a span of time. I currently
have it working fine when I start a new record.

However, I have not figured out how to have it record the time when I leave
the record.

Additionally, I'd like to have it freeze those two times and not change
again if I re-enter that same record. I just want it to freeze those two
times -- time record started and time record left and then never change
again.

Thank you for your help.
 
T

tina

presumably you have a StartTime field and an EndTime field in the table
that's bound to the form, each with a data type of Date/Time. in the form's
BeforeInsert event procedure, add the following code, as

Private Sub Form_BeforeInsert(Cancel As Integer)

Me!StartTime = Now()

End Sub

the BeforeInsert event only runs when you begin entering data in a *new*
record in a form.

next, add the following code to the form's BeforeUpdate event procedure, as

Private Sub Form_BeforeUpdate(Cancel As Integer)

If Me.NewRecord Then
Me!EndTime = Now()
End If

End Sub

hth
 
G

Guest

Thank you so much. I do have the fields but was stuck on the coding and the
approrpriate event. I'm anxious to try it tomorrow.
 
G

Guest

This worked great! One other quick question if you don't mind. Of course. I
want to calculate the difference in h, m, and s. I can get the s to work,
but not the h and m.

This is what I currently have in my field.
=DateDiff("s",[TimeStarted],[TimeClosed]).

Would it be best that I just do all this in seconds and then divide
accordingly?
 
T

tina

that's what i'd do - get the difference in the smallest common denominator,
and then divide and concatenate. ;)

hth


ztyco said:
This worked great! One other quick question if you don't mind. Of course. I
want to calculate the difference in h, m, and s. I can get the s to work,
but not the h and m.

This is what I currently have in my field.
=DateDiff("s",[TimeStarted],[TimeClosed]).

Would it be best that I just do all this in seconds and then divide
accordingly?

tina said:
you're welcome :)
post back if you have any trouble with it.


and
the procedure,
as those
two
 
G

Guest

Great! Thanks again!

tina said:
that's what i'd do - get the difference in the smallest common denominator,
and then divide and concatenate. ;)

hth


ztyco said:
This worked great! One other quick question if you don't mind. Of course. I
want to calculate the difference in h, m, and s. I can get the s to work,
but not the h and m.

This is what I currently have in my field.
=DateDiff("s",[TimeStarted],[TimeClosed]).

Would it be best that I just do all this in seconds and then divide
accordingly?

tina said:
you're welcome :)
post back if you have any trouble with it.


Thank you so much. I do have the fields but was stuck on the coding and
the
approrpriate event. I'm anxious to try it tomorrow.

:

presumably you have a StartTime field and an EndTime field in the table
that's bound to the form, each with a data type of Date/Time. in the
form's
BeforeInsert event procedure, add the following code, as

Private Sub Form_BeforeInsert(Cancel As Integer)

Me!StartTime = Now()

End Sub

the BeforeInsert event only runs when you begin entering data in a *new*
record in a form.

next, add the following code to the form's BeforeUpdate event procedure,
as

Private Sub Form_BeforeUpdate(Cancel As Integer)

If Me.NewRecord Then
Me!EndTime = Now()
End If

End Sub

hth


I have a form that I'd like to use to measure a span of time. I
currently
have it working fine when I start a new record.

However, I have not figured out how to have it record the time when I
leave
the record.

Additionally, I'd like to have it freeze those two times and not
change
again if I re-enter that same record. I just want it to freeze those
two
times -- time record started and time record left and then never
change
again.

Thank you for your help.
 
T

tina

you're welcome :)


ztyco said:
Great! Thanks again!

tina said:
that's what i'd do - get the difference in the smallest common denominator,
and then divide and concatenate. ;)

hth


ztyco said:
This worked great! One other quick question if you don't mind. Of course. I
want to calculate the difference in h, m, and s. I can get the s to work,
but not the h and m.

This is what I currently have in my field.
=DateDiff("s",[TimeStarted],[TimeClosed]).

Would it be best that I just do all this in seconds and then divide
accordingly?

:

you're welcome :)
post back if you have any trouble with it.


Thank you so much. I do have the fields but was stuck on the
coding
and
the
approrpriate event. I'm anxious to try it tomorrow.

:

presumably you have a StartTime field and an EndTime field in
the
table
that's bound to the form, each with a data type of Date/Time. in the
form's
BeforeInsert event procedure, add the following code, as

Private Sub Form_BeforeInsert(Cancel As Integer)

Me!StartTime = Now()

End Sub

the BeforeInsert event only runs when you begin entering data in
a
*new*
record in a form.

next, add the following code to the form's BeforeUpdate event procedure,
as

Private Sub Form_BeforeUpdate(Cancel As Integer)

If Me.NewRecord Then
Me!EndTime = Now()
End If

End Sub

hth


I have a form that I'd like to use to measure a span of time. I
currently
have it working fine when I start a new record.

However, I have not figured out how to have it record the time when I
leave
the record.

Additionally, I'd like to have it freeze those two times and not
change
again if I re-enter that same record. I just want it to
freeze
those
two
times -- time record started and time record left and then never
change
again.

Thank you for your help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top