PC Review


Reply
Thread Tools Rate Thread

Calculatting Time difference

 
 
=?Utf-8?B?R3JlZw==?=
Guest
Posts: n/a
 
      27th Oct 2007
I have a form where I am entering all issues. On this form I placed subform
where I am displaying issues that are still open and not resolved. I want to
display time difference between current time and the last update. Here is
the code I am using:


Private Sub Form_Timer()

Dim sngElapsedTime As Date
Dim Last_Update As Date
'determine the amount of time that has elapse between last update
' and now.
sngElapsedTime = Now() - [Last Update]
'Update the timer
txtTimeDiff = Format(sngElapsedTime, "hh:mm:ss")

End Sub

Timer interval is set to 1000 so the difference is updated every second but
calculation works only for first record on this subform. If I have 3 records
same time is displayed for all 3 records. For example if difference for
first record is 50 min, that difference is displayed for every record on this
subform even if time difference for second record is 30 min. How I can
calculate time difference for each individual record on my subform?

Also how I can display popup warning message informing that time difference
is greater then 60 min?

 
Reply With Quote
 
 
 
 
Tom van Stiphout
Guest
Posts: n/a
 
      27th Oct 2007
On Sat, 27 Oct 2007 01:12:00 -0700, Greg
<(E-Mail Removed)> wrote:

This problem occurs because the control with the calculated value is
not bound to a field in a table. So here you have to make a decision.
If you badly want the current design and functionality, you'll need to
violate a db design rule that says "no calculated values" in tables,
and add the field.
Then update the values using an Update query. I hope you'll consider
running it less frequently than once a second. Something like:
Update SomeTable set MyCalculatedField = DateDiff("d", Now(), [Last
Update])
Then apply the format in your control.
The condition for >60 minutes I would handle with conditional
formatting, setting the background to Red.

-Tom.


>I have a form where I am entering all issues. On this form I placed subform
>where I am displaying issues that are still open and not resolved. I want to
>display time difference between current time and the last update. Here is
>the code I am using:
>
>
>Private Sub Form_Timer()
>
> Dim sngElapsedTime As Date
> Dim Last_Update As Date
> 'determine the amount of time that has elapse between last update
> ' and now.
> sngElapsedTime = Now() - [Last Update]
> 'Update the timer
> txtTimeDiff = Format(sngElapsedTime, "hh:mm:ss")
>
>End Sub
>
>Timer interval is set to 1000 so the difference is updated every second but
>calculation works only for first record on this subform. If I have 3 records
>same time is displayed for all 3 records. For example if difference for
>first record is 50 min, that difference is displayed for every record on this
>subform even if time difference for second record is 30 min. How I can
>calculate time difference for each individual record on my subform?
>
>Also how I can display popup warning message informing that time difference
>is greater then 60 min?

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference between Windows Time Service and Internet Time in Date & Time Properties Saucer Man Windows XP General 0 14th Feb 2008 01:51 PM
subtract the time difference from another time difference =?Utf-8?B?RGFubmlnaXJs?= Microsoft Excel Misc 3 30th Sep 2007 03:47 PM
Comparing 2 files on date/time stamp, and based time difference do a subroutine info@stevik.nl Microsoft Excel Programming 1 28th Sep 2007 03:53 AM
How can I find records based upon a date and time range while accounting for time zone difference BJC Microsoft Access 2 11th Jul 2007 01:13 AM
Time difference error with no time difference Rob Oldfield Microsoft Windows 2000 Security 0 5th Mar 2004 10:33 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:51 PM.