UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Conditional Blinking Value, Any Version    
 
   
FrankRuperto
post Feb 14 2020, 02:30 PM
Post#1



Posts: 664
Joined: 21-September 14
From: (MilitaryBrat) Tampa Bay, Florida, USA


I have a user who is obsessed with having the DaysInterestDue value in active contracts blink in red ForeColor when days > 89, and no blinking in yellow when days < 90. I dont see font blinking in the property sheet's format tab, so I'm assuming I have to put a timer interval with 500 ticks on the following code in OnOpen form event to toggle the blinking? I also have nav butons for scrolling through all contract childs belonging to a customer parent. The elapsed days vary as user scrolls through active contracts and not visible when contract status is inactive.

CODE
If Me.txtDaysInterestDue.Value > 89 Then
Me.txtDaysInterestDue.ForeColor = vbRed
Me.txtDaysInterestDue.ForeColor = vbBlack
Else
Me.txtDaysInterestDue.ForeColor = vbYellow
EndIf



Attached File(s)
Attached File  ConditionalBlinkingDays.PNG ( 789.76K )Number of downloads: 15
 

--------------------
Currently supporting pawnbrokers that use my store management system developed with Access 2010 on Windows7. Experienced with Informix and Oracle DB's.
Go to the top of the page
 
DanielPineault
post Feb 14 2020, 02:33 PM
Post#2


UtterAccess VIP
Posts: 7,154
Joined: 30-June 11



In the case of <89 I set the timer = 0 to stop it for running again and again and ... for no reason
In the case of >89 you'll need to use the timer and keep change the font color back and forth

--------------------
Daniel Pineault (2010-2019 Microsoft MVP, UA VIP, EE Distinguished Expert 2018)
Professional Help: https://www.cardaconsultants.com
Free MS Access Code, Tips, Tricks and Samples: https://www.devhut.net

* Design should never say "Look at me". It should always say "Look at this". -- David Craib
* A user interface is like a joke, if you have to explain it, it's not that good! -- Martin LeBlanc


All code samples, demonstration databases, links,... are provided 'AS IS' and are to be used at your own risk! Take the necessary steps to check, validate ...(you are responsible for your choices and actions)
Go to the top of the page
 
FrankRuperto
post Feb 14 2020, 02:42 PM
Post#3



Posts: 664
Joined: 21-September 14
From: (MilitaryBrat) Tampa Bay, Florida, USA


You're right, why keep timer running when no blinking is needed, thanks!
So then something like this?

CODE
If Me.txtDaysInterestDue.Value > 89 Then
Me.txtDaysInterestDue.ForeColor = vbRed
Me.txtDaysInterestDue.ForeColor = vbBlack
Else
Timer() = 0
Me.txtDaysInterestDue.ForeColor = vbYellow
EndIf


ADDENDUM: I already have an autologout timer if app is inactive 10 minutes. Can I have more than one timer active?
This post has been edited by FrankRuperto: Feb 14 2020, 03:13 PM

--------------------
Currently supporting pawnbrokers that use my store management system developed with Access 2010 on Windows7. Experienced with Informix and Oracle DB's.
Go to the top of the page
 
FrankRuperto
post Feb 14 2020, 04:00 PM
Post#4



Posts: 664
Joined: 21-September 14
From: (MilitaryBrat) Tampa Bay, Florida, USA


Hmm, this doesnt work in the form's OnLoad event iconfused.gif

CODE
If Me.txtDaysInterestDue.Value > 89 Then
Me.txtDaysInterestDue.ForeColor = vbRed
Me.TimerInterval = 500
Me.txtDaysInterestDue.ForeColor = vbBlack
Else
Me.TimerInterval = 0
Me.txtDaysInterestDue.ForeColor = vbYellow
EndIf

This post has been edited by FrankRuperto: Feb 14 2020, 04:03 PM

--------------------
Currently supporting pawnbrokers that use my store management system developed with Access 2010 on Windows7. Experienced with Informix and Oracle DB's.
Go to the top of the page
 
cheekybuddha
post Feb 14 2020, 05:04 PM
Post#5


UtterAccess Moderator
Posts: 12,375
Joined: 6-December 03
From: Telegraph Hill


The TimerInterval is used in conjuction with the Timer event.
CODE
Private Sub Form_Timer()

  With Me.txtDaysInterestDue
    If .ForeColor = vbRed Then
      .ForeColor = vbBlack
    Else
      .ForeColor = vbRed
    End If
  End WIth

End Sub

Private Sub Form_Current()

' Repeat this code in the AfterUpdate event of any control that changes txtInterestDue
  If CheckDue Then
    Me.TimerInterval = 500
  Else
    Me.TimerInterval = 0
    Me.txtDaysInterestDue.ForeColor = vbYellow
  End If

End Sub

Private Function CheckDue() As Boolean

  CheckDue = Nz(Me.txtDaysInterestDue, 0) > 89

End Function

--------------------


Regards,

David Marten
Go to the top of the page
 
FrankRuperto
post Feb 14 2020, 11:21 PM
Post#6



Posts: 664
Joined: 21-September 14
From: (MilitaryBrat) Tampa Bay, Florida, USA


Wow, thanks thumbup.gif My mind was stuck on thinking that timer is a built-in function and not an event in form properties. I've never tinkered with vba timers. I was ill-advised to avoid them because they're "problematic and make debugging difficult". So with your code, do I set the TimerInterval in form properties to zero?

As I previously mentioned, my app's first developer created an autologout public function that was supposed to trigger after X minutes of user inactivity, but the app was logging us out every time we encountered a debug error, making it virtually impossible to perfect this app. My current dev set the timeout value to zero and changed the function's datatype to a TempVars and this basically disabled the autologout feature. However, dev did not remove the timer-related code for fear of the app breaking all over the place. Every form in this app still has that disabled autologout OnTimer procedure. Do we have to remove it from contract form in order to implement the new conditional blinking value?

Every day I am more convinced that we will have to refactor this vertical market app's code because I have already seen its fragility when making mods to it frown.gif
This post has been edited by FrankRuperto: Feb 14 2020, 11:40 PM

--------------------
Currently supporting pawnbrokers that use my store management system developed with Access 2010 on Windows7. Experienced with Informix and Oracle DB's.
Go to the top of the page
 
cheekybuddha
post Feb 15 2020, 10:24 AM
Post#7


UtterAccess Moderator
Posts: 12,375
Joined: 6-December 03
From: Telegraph Hill


>> So with your code, do I set the TimerInterval in form properties to zero? <<

Yes you can, but it's not necessary as it will be set anyway when the form first loads and the Current event fires.

Remember, in Access, Timers are per form. Any form open in Normal View that has Form_Timer code and TimerInterval > 0 will run its timer. Whenever you are debugging/coding you must make sure all such forms are closed or in Design View otherwise the VBA editor will compile whatever code you are working on when a timer event fires.

>> My current dev set the timeout value to zero and changed the function's datatype to a TempVars and this basically disabled the autologout feature <<

Normally autlogout code will reside in a single form's timer and that form should remain open always whilst your app is running (even if hidden) eg. like a switchboard form.

Actions on your other forms (like click or data entry or mousemove) can update a global variable/TempVar/table record which the autologout code checks to determine if any user interaction has taken place and whether to log the user out.

Such a form would need to be closed or in Design View if you are trying to debug or write code.

hth,

d

--------------------


Regards,

David Marten
Go to the top of the page
 
Jeff B.
post Feb 15 2020, 10:28 AM
Post#8


UtterAccess VIP
Posts: 10,381
Joined: 30-April 10
From: Pacific NorthWet


JOPO

Some folks have had seizures triggered by blinking red lights. Let's hope your 'user' isn't one...

--------------------
Regards

Jeff Boyce
Microsoft Access MVP (2002-2015)

Mention of hardware or software is, in no way, an endorsement thereof. The FTC of the USA made this disclaimer necessary/possible.
Go to the top of the page
 
FrankRuperto
post Feb 15 2020, 12:27 PM
Post#9



Posts: 664
Joined: 21-September 14
From: (MilitaryBrat) Tampa Bay, Florida, USA


Jeff B.

Since year 1984, the legacy app has the red blinking days in the contract form. Never got any complaints about it. Several asked me why it doesnt blink in the Access version. In legacy, it was very simple to implement the conditional red blink.

In that field's attributes all I had to include was
CODE
color = yellow, color = red blink where txtDaysInterestDue > 89

CheekyBuddha,

QUOTE
Remember, in Access, Timers are per form.


Understood, so this means I will have to remove the current OnTimer event in that form in order to implement the new timer for the red blinking field, because you cant have more than one timer defined per form? The contract form is modal and never opens by itself, there's always a customer parent form that opens first, and that cust form also has a timer. The switchboard form is the first form that opens when launching app. It always stays open and also has a timer. Does this complicate things?

My devs next task is going to be to clean up this app, including removing all these autologout timers that should've never been included in each form in the first place. We want to add new features to this app and the timers plus obfuscated code is a big obstacle.

Thanks for all your help thumbup.gif
This post has been edited by FrankRuperto: Feb 15 2020, 12:27 PM

--------------------
Currently supporting pawnbrokers that use my store management system developed with Access 2010 on Windows7. Experienced with Informix and Oracle DB's.
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    26th February 2020 - 01:27 PM