473,406 Members | 2,849 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Time trigger doesn't work

I set up 2 time fields and when the first field[CDAsAlarm] gets to the value of the second[CurrentTime], I want the first fields' border to blink. The CurrentTime updates correctly when the form loads, but the CDAsAlarm stays blinking or solid(depending whether I use < or >), even after the currentTime reaches the CDAsAlarm time. I would like it to automatically stop blinking with the passage of time...Thanks, jc

Here is the code...
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.    Me.CurrentTime = Now()
  3.  
  4.    Me.TimerInterval = 400
  5. End Sub
  6.  
  7. Private Sub Form_Timer()
  8.  
  9. Dim DateTimeval As Date
  10. Dim CurrentTime As Date
  11. Dim  tm, CDAtm
  12.  
  13.     DateTimeval = Me.CurrentTime.Value 
  14.     tm = Format(DateTimeval, "hh:mm")
  15.     CDAtm = Format(DateTimeval, "hh,mm")
  16.     Me.CurrentTime = Now() 
  17.     Me.TimerInterval = 400
  18.  
  19.      If CDAtm < tm Then
  20.         With Me.CDAsAlarm
  21.          .BorderColor = (IIf(.BorderColor = vbGreen, vbRed, vbGreen))
  22.         End With
  23.         Else
  24.         With Me.CDAsAlarm
  25.          .BorderColor = vbGreen
  26.         End With
  27.     End If
Aug 11 '11 #1
5 1972
NeoPa
32,556 Expert Mod 16PB
Your question doesn't really explain what you're trying to do very well I'm afraid. Unfortunately, your code is similarly unclear. I'm going to guess you want the CurrentTime control (You have no fields in the whole problem BTW) to flash when, and only when, the displayed time in hh:mm format matches the hh:mm format of the CDAsAlarm control.

For that the following code should indicate some concepts that will help :
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Private Const conRG As Long = vbRed + vbGreen
  5.  
  6. Private Sub Form_Load()
  7.     With Me
  8.         .CurrentTime = Format(Now(), "HH:mm")
  9.         .TimerInterval = 400
  10.     End With
  11. End Sub
  12.  
  13. Private Sub Form_Timer()
  14.     Dim strTime As String
  15.  
  16.     With Me
  17.         With .CurrentTime
  18.             .Value = Format(Now(), "HH:mm")
  19.             strTime = .Value
  20.         End With
  21.         With .CDAsAlarm
  22.             If strTime = Format(CDate(.Value), "HH:mm") Then
  23.                 .BorderColor = conRG - .BorderColor
  24.             Else
  25.                 .BorderColor = vbGreen
  26.             End If
  27.         End With
  28.     End With
  29. End Sub
** Edit **
This code has been changed retrospectively as I noticed that the control CurrentTime was not being updated regularly to reflect the current time (Doh!).
Aug 11 '11 #2
I wanted the text box to blink if its content passed a certain time,so I changed the = to > on the " If strTime = Format..." line; and it worked perfectly.
Thank you very much,
jc
Aug 11 '11 #3
NeoPa
32,556 Expert Mod 16PB
John Carter:
I would like it to automatically stop blinking with the passage of time
The suggested code would actually work too. It just doesn't stop there. It turns the blinking off after a minute (as hinted at by your comment (quoted) in the original question). Unfortunately the question isn't very clear about exactly what's required there, but clearly you don't seem to want it to continue blinking, so I'd consider putting the code back as suggested, or alternatively replacing it with something to do the job that you want. I can't help there unless you tell us what that is of course.
Aug 12 '11 #4
I read my first request and I can see that I need some technical writing practice...:-) And since you ask, I am creating several fields on one form,each field needing to have it's borders start blinking if it doesn't have data in it when it hits a time threshhold during any given day. Each field has a different threshhold(Trig#). Currently I have 3 fields CDAs1, CDAs2, and CDAs3; each of these 3 fields has it's own trigger field Trig1, Trig2, and Trig3(each trig with a uinique #hh:mm# value). And finally there is a single CurrentTime field which the whole form uses to monitor the status of the CDAs fields. The previous code you gave works for a single field, but I can't get to work for multiple fields. Any ideas? (And thank you very much for you patience...)
Sincerely,
John
Aug 13 '11 #5
NeoPa
32,556 Expert Mod 16PB
John Carter:
I can see that I need some technical writing practice...:-)
Very rare vision John. I like it. Your latest post though, is an example of clarity and a pleasure to work to (Controls on a form are not fields, they are ... controls - but worrying about that now would be just picky :-D)

Now I've had a chance to review the code I noticed a fundamental problem with my previous version (which I fixed - not in order to confuse you, but simply so anyone else reading this will not pick up any bum direction from me). I had forgotten to ensure that Me.CurrentTime was kept updated as time passed. Not only that, but the fact of handling checks against multiple controls has meant the logic of the code is somewhat different from the previous version. See what you make of it :

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Private ctlNow As Control
  5.  
  6. Private Sub Form_Load()
  7.     With Me
  8.         Set ctlNow = .CurrentTime
  9.         With ctlNow
  10.             .Locked = False
  11.             .Value = Format(Now(), "HH:mm")
  12.             .Locked = True
  13.         End With
  14.         .TimerInterval = 400
  15.     End With
  16. End Sub
  17.  
  18. Private Sub Form_Timer()
  19.     Dim datTrig As Date
  20.     Dim ctlCDAs As Control
  21.  
  22.     With Me
  23.         With ctlNow
  24.             .Locked = False
  25.             .Value = Format(Now(), "HH:mm")
  26.             .Locked = True
  27.         End With
  28.         For Each ctlCDAs In .Controls
  29.             With ctlCDAs
  30.                 If Left(.Name, 4) = "CDAs" Then
  31.                     If .BorderColor = vbRed Then
  32.                         .BorderColor = vbGreen
  33.                     Else
  34.                         datTrig = CDate(Me.Controls("Trig" & Mid(.Name, 5)))
  35.                         If Format(datTrig, "HH:mm") = ctlNow Then .BorderColor = vbRed
  36.                     End If
  37.                 End If
  38.             End With
  39.         Next ctlCDAs
  40.     End With
  41. End Sub
PS. I'm assuming Me.CurrentTime is a TextBox control. It may make sense to make it a label instead, then you needn't include code to ensure the operator never fiddles with it ;-)
Aug 13 '11 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Darrell Blake | last post by:
I'm trying to use sessions to allow people to log into my site. The problem is that sometimes it works and sometimes it doesn't! As far as I'm aware my script is fine (hence why it works sometimes)...
19
by: Chris Allen | last post by:
Hi I'm new to PHP and I'm trying to create a Login Form. Once the user has logged in then he shouldn't have to log in again. The trouble is I'm getting a new session ID between every page and so...
9
by: Martin Häcker | last post by:
Hi there, I just tried to run this code and failed miserably - though I dunno why. Could any of you please enlighten me why this doesn't work? Thanks a bunch. --- snip --- import unittest...
2
by: Iver Erling Årva | last post by:
I have come across a problem with the onKeyDown event in some of my forms. I'm using onKeyDown in <form> as a standard method to open my help screen system throughout my system, but I have...
16
by: Josué Maldonado | last post by:
Hello list, The TCL trigger that uses NEW and OLD arrays failed after after I removed a unused column, now I got this error: pltcl: Cache lookup for attribute '........pg.dropped.24........'...
3
by: BLUE WATER | last post by:
Hi, I have managed to simplify my problem but can't seem to get this to work. I want to open up a form from a click event of another form, but not only open the form when the button is pressed...
0
by: Dica | last post by:
if i set the interval of my timer control above 259, timer_elapsed doesn't ever seem to fire. even with lower values that have worked previously, i'm still getting the periodic timer_elapsed...
1
by: mathewda | last post by:
Hey, I'm having a problem that I consider kinda weird that is alluding me at the moment. I've wrote some code that will set up an XMLHttpRequest, it then makes a call to open and send and sets the...
2
by: Morgan Cheng | last post by:
I have one webservice A calling another webserivce B. B is time costing and sometimes the response takes more than 160 seconds. A is supposed to be Thread.Abort in 90 seconds. However, the 90...
3
by: =?Utf-8?B?Um9nZXIgTWFydGlu?= | last post by:
Note: My apologies for repeating this post from last week, but my nospam alias and profile account were incorrect. I think I have fixed this, so hopefully this post will trigger MS into a response...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.