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... - Private Sub Form_Load()
-
Me.CurrentTime = Now()
-
-
Me.TimerInterval = 400
-
End Sub
-
-
Private Sub Form_Timer()
-
-
Dim DateTimeval As Date
-
Dim CurrentTime As Date
-
Dim tm, CDAtm
-
-
DateTimeval = Me.CurrentTime.Value
-
tm = Format(DateTimeval, "hh:mm")
-
CDAtm = Format(DateTimeval, "hh,mm")
-
Me.CurrentTime = Now()
-
Me.TimerInterval = 400
-
-
If CDAtm < tm Then
-
With Me.CDAsAlarm
-
.BorderColor = (IIf(.BorderColor = vbGreen, vbRed, vbGreen))
-
End With
-
Else
-
With Me.CDAsAlarm
-
.BorderColor = vbGreen
-
End With
-
End If
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 : - Option Compare Database
-
Option Explicit
-
-
Private Const conRG As Long = vbRed + vbGreen
-
-
Private Sub Form_Load()
-
With Me
-
.CurrentTime = Format(Now(), "HH:mm")
-
.TimerInterval = 400
-
End With
-
End Sub
-
-
Private Sub Form_Timer()
-
Dim strTime As String
-
-
With Me
-
With .CurrentTime
-
.Value = Format(Now(), "HH:mm")
-
strTime = .Value
-
End With
-
With .CDAsAlarm
-
If strTime = Format(CDate(.Value), "HH:mm") Then
-
.BorderColor = conRG - .BorderColor
-
Else
-
.BorderColor = vbGreen
-
End If
-
End With
-
End With
-
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!).
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
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.
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
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 : - Option Compare Database
-
Option Explicit
-
-
Private ctlNow As Control
-
-
Private Sub Form_Load()
-
With Me
-
Set ctlNow = .CurrentTime
-
With ctlNow
-
.Locked = False
-
.Value = Format(Now(), "HH:mm")
-
.Locked = True
-
End With
-
.TimerInterval = 400
-
End With
-
End Sub
-
-
Private Sub Form_Timer()
-
Dim datTrig As Date
-
Dim ctlCDAs As Control
-
-
With Me
-
With ctlNow
-
.Locked = False
-
.Value = Format(Now(), "HH:mm")
-
.Locked = True
-
End With
-
For Each ctlCDAs In .Controls
-
With ctlCDAs
-
If Left(.Name, 4) = "CDAs" Then
-
If .BorderColor = vbRed Then
-
.BorderColor = vbGreen
-
Else
-
datTrig = CDate(Me.Controls("Trig" & Mid(.Name, 5)))
-
If Format(datTrig, "HH:mm") = ctlNow Then .BorderColor = vbRed
-
End If
-
End If
-
End With
-
Next ctlCDAs
-
End With
-
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 ;-)
Sign in to post your reply or Sign up for a free account.
Similar topics
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)...
|
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...
|
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...
|
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...
|
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........'...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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...
|
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...
|
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,...
|
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...
| |