Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Special FX problem - at the whim of a client - please read :)??

Status
Not open for further replies.

kimi2001

Technical User
Sep 18, 2001
6
GB
Hello,

I am using Access 2000 and what my client has asked me to do is have like a "traffic light" text flashing effect. Completely usless of course, but we are all at the wim of our clients or bosses I guess.

What I mean by a traffic light effect is this

Lets say there are 3 label boxes on a form called frmParent (the captions dont matter at this time), lab1, lab2 and lab3.
I need the .forcolor of lab1 to be red for 1/2 a second and the other two to be black, then lab1 turns black at the same time as lab2 turns red for 1/2 a second (while lab3 stays black.
Then, yes you have guessed it, lab3 turns red for 1/2 a second while the other two are black. This would be on a constant loop so it looks like lab1,2, and 3 are part of a overall effect.

I have tried the parent forms OnTimer event but as my knowledge lets me down, i can only get all three to flash red at the same time. I am completely stumped as to what to do because the client insists on having this.

Is there a way of telling Access to perform "task A = setting forcolor of lab1 to vRed and lab2 and 3 to vbBlack then,
1/2 a second later Access should perform "task B = setting forcolor of lab1 and 3 to vbBlack and the forcolor of lab2 ro vbRed, then
1/2 a second later Access performs "task C = setting the forcolor of lab3 to vbRed and lab1 and 2 to vbBlack then
1/2 a second later, repetes the whole process ???

I am hoping that someone can point me in the right direction?

Thanks in advance
 
create a Subroutine called every 1/2 a second by the ontimer event and pass a value,

Global strTrafficLight as String

where values are: red, yellow green

the Sub could be called

Public Sub SwicthLight(myColor as String)

Select Case myColor

Case "Red":
Lab1.forecolor = "RED"
Lab2.forecolor = "BLACK"
Lab3.forecolor = "BLACK"
strTrafficLight = "yellow"
Case "Yellow":
Lab1.forecolor = "BLACK"
Lab2.forecolor = "YELLOW"
Lab3.forecolor = "BLACK"
strTrafficLight = "green"
Case "Green":
Lab1.forecolor = "BLACK"
Lab2.forecolor = "BLACK"
Lab3.forecolor = "GREEN"
strTrafficLight = "red"
end select

end Sub

hth
Alcar
 
make that

Case Is "Red"

see what happens when I don't eat at lunhc?? I need a brake =P
Alcar
 
Certainly not a big difference, but if IDX is defined as static within the onTimer event:

'Stop light action
lblRed.ForeColor = RGB(0, 0, 0)
lblYel.ForeColor = RGB(0, 0, 0)
lblGrn.ForeColor = RGB(0, 0, 0)
Select Case Idx
Case Is = 0
Idx = 1
Case Is = 1
lblRed.ForeColor = RGB(255, 0, 0)
Idx = 2
Case Is = 2
lblYel.ForeColor = RGB(255, 255, 0)
Idx = 3
Case Is = 3
lblGrn.ForeColor = RGB(0, 255, 0)
Idx = 1
End Select
also works. MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Erm, yeah ok guys - heh heh.

1st, Thanks for taking the time to reply, and 2nd, I am a bit confused!!

Where exactly should I put this code, on the forms on open event ???

I have tried that with both codes above, and nither work, Access just starts chuckin errors.

Also, should I not have a TimerInterval in the sub to specify the time between the colours changing (approx every 1/2 a second is best I think) together with a means of triggering the whole thing off ???

Kind regards,

A confused kimi.
 
Confused. The timer interval is a property of the FORM obkect. You can set it via code, but the more common approach for something which runs 'forever' is to do it statically in the form's design view.

Code:
Private Sub OnTimer()
    Static Idx

    lblRed.ForeColor = RGB(0, 0, 0)
    lblYel.ForeColor = RGB(0, 0, 0)
    lblGrn.ForeColor = RGB(0, 0, 0)
    Select Case Idx
        Case Is = 0
            Idx = 1
        Case Is = 1
            lblRed.ForeColor = RGB(255, 0, 0)
            Idx = 2
        Case Is = 2
            lblYel.ForeColor = RGB(255, 255, 0)
            Idx = 3
        Case Is = 3
            lblGrn.ForeColor = RGB(0, 255, 0)
            Idx = 1
    End Select
End Sub
MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
of Course, to use the code I provided you will need to adjust the control names so that the code and the control names 'match'. From your response, and a review of the original problem statement I am (mentally) substutiting "Teacher / Instructor" for "Cllient".

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top