• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 308
  • Last Modified:

have bmp img file on form appear to be flashing

hello,
have attached sample db.
open database and form opens.
if you enter 123 for serial number and hit enter- a lemon bmp image file becomes visible-
(logic is if there is more than 2 records with same serial number the image is visible)
question:
Is there a way with timer interval (or something else) to make image look like it is flashing (when it is visible)?
thank you-
Data1.accdb
0
davetough
Asked:
davetough
  • 2
  • 2
1 Solution
 
mbizupCommented:
I can't download your database, but this is the basic idea:

In the same code where you make the image visible, add the following line:

Me.TimerInterval = 1000  'This will execute your timer event every second

Open in new window


Then in the timer event:


'This toggles the visibility of the image (flashes it)
Me.imgMyImage.Visible = Not Me.imgMyImage.Visible

Open in new window



And if you want to turn off the timer/flashing:

Me.TimerInterval = 0 'This will turn off your timer and stop the flashing

Open in new window

0
 
davetoughAuthor Commented:
Thanks- i wonder if my example is corrupted-
i placed code:

Private Sub serial_AfterUpdate()
Me.txtCount = DCount("*", "tblServer", "serial='" & Me.serial & "'")
If Me.txtCount > 2 Then
Me.TimerInterval = 1000
Me.imgLemon.Visible = True

Else
Me.imgLemon.Visible = False
End If

End Sub

in textbox- logic- when more than 2 same serial numbers - image displays-
can i use image like this?

am having hard time finding timerinterval- thought it was just in properties of image?
or maybe am not doing something right here
thank you
0
 
mbizupCommented:
<<thought it was just in properties of image? >>

No... Timer Interval and the Timer Event are associated with the form itself.  So try this:


Private Sub serial_AfterUpdate()
   Me.txtCount = DCount("*", "tblServer", "serial='" & Me.serial & "'")
   If Me.txtCount > 2 Then
      Me.TimerInterval = 1000
      Me.imgLemon.Visible = True

    Else
       Me.imgLemon.Visible = False
       Me.TimerInterval = 0   '<---- This turns off the flashing
   End If

Open in new window


You  might also need the above code in the current event of your form.


And use the timer event of the form as I described earlier:

Private Sub Form_Timer()


'This toggles the visibility of the image (flashes it)
Me.imgLemon.Visible = Not Me.imgLemon.Visible

End Sub

Open in new window

0
 
davetoughAuthor Commented:
thank you for explanation and code-
0
 
Jeffrey CoachmanCommented:
<No Points wanted>
Just note that the timer is low on the processors priority list.
So the flashing may not be as "Consistent" as you might want...

For example this might be an ideal  1 second Flash:
On..........Off..........On..........Off..........ON..........Off

But in reality the flashing might end up being like this:
On..........Off................On..Off.......ON..Off.............
(Not here that the "Total Time" is the same, but the flashing is irregular)

...So the flashing may be off depending on what else the computer has running.

It also can cause odd things to happen if you open the VB editor while it is running.

JeffCoachman
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now