Make a label "flash" on a form

  • Thread starter Matthew Reed via AccessMonster.com
  • Start date
M

Matthew Reed via AccessMonster.com

I have a switchboard that has a label on it that I want to flash on the
screen, meaning visible for a second, then invisible, visible, etc.

I have a "TestVis" macro that runs on the On Timer property, with the Timer
Interval set to 3000 (so every 3 seconds).

The TestVis macro should make the label visible if it isn't, then make it
invisible three seconds later. I'm using a SetValue action to set the
Visible property of the label to yes or no.

If I set the Visible property of the label to Yesin Design View, then open
the form, it makes it invisible -- ONCE.
If I set the Visible property of the label to No, then open the form, it
makes it visible -- ONCE.

It's as if the property isn't getting saved...Access still thinks it's
visible if it's not. I tried a Save Form action, no luck.

Any thoughts? I'm missing something about the way control properties can be
set and tested...
 
G

Guest

Hi, Matthew.

I can't help you understand WHY it's not working, but with the Form's Timer
Interval property set to 3000, the following code in the OnTimer event
procedure worked flawlessly on a test form:

MyLabel.Visible = Not MyLabel.Visible

If you've never created a VBA subroutine before, click on the ellipsis to
the right of the OnTimer event property, and choose Code Builder. Access
will create the shell of a routine for you. Insert the code above between
the Sub and End Sub lines, changing the two instances of "MyLabel" to the
name of your label.

Hope that helps.
Sprinks
 
G

Guest

Matthew,

I forgot to mention in my post that while macros are sometimes a quick &
dirty solution, they are very limited. Litwin, Getz, & Gilbert's point out
in "Access 97 Developer's Handbook, p.17, that they:

- can't recover from errors
- can't be used to call DLL's
- can't easily be used for looping
- can't be used to step through recordsets
- can't be used in transaction processing
- can't pass parameters
- are difficult to debug
- can be halted by users with Ctrl+Break

While VBA certainly has a learning curve to understand its objects, methods
& properties, it will seem much more straightforward once you understand it.
Some good ways to learn it are to study the code behind the forms in the
Northwind application, creating command buttons with the wizard & doing the
same, getting a good reference book, and using VBA Help, which is pretty
comprehensive.

Sprinks
 
G

Guest

Matthew has some excellent points. Macros were designed for the
inexperienced to build simple "home brew" databases. They really have no
place in a business environment, especially if the user is not also the
developer.

In addition to the other suggestions Matthew offered, It would help you
understand how VBA is working if you convert each macro to VBA and study how
the VBA is accomplishing what the macro was written to do.
 
D

Dirk Goldgar

Klatuu said:
In addition to the other suggestions Matthew offered, It would help
you understand how VBA is working if you convert each macro to VBA
and study how the VBA is accomplishing what the macro was written to
do.

That's a good point. It does have the drawback that often the
simplistic way a macro is translated to VBA doesn't reflect the best way
to get the job done. Macro translations tend to follow the user
interface, but a lot of VBA's power comes from the way it lets you work
directly with the object model.
 
G

Guest

I agree, Dirk; however, I still believe it is a good starting point. If a
person is completely unfamiliar with programming, but can write a macro, then
there is a point of relation there that can be used as a starting point.
 
M

Matthew Reed via AccessMonster.com

Terrific -- thanks for this. It worked. And thanks to all for suggesting
more VBA knowledge on my part. I certainly agree and have been up against
Macro limitations for some time now. I'll take it to heart.

Matt
Hi, Matthew.

I can't help you understand WHY it's not working, but with the Form's Timer
Interval property set to 3000, the following code in the OnTimer event
procedure worked flawlessly on a test form:

MyLabel.Visible = Not MyLabel.Visible

If you've never created a VBA subroutine before, click on the ellipsis to
the right of the OnTimer event property, and choose Code Builder. Access
will create the shell of a routine for you. Insert the code above between
the Sub and End Sub lines, changing the two instances of "MyLabel" to the
name of your label.

Hope that helps.
Sprinks
I have a switchboard that has a label on it that I want to flash on the
screen, meaning visible for a second, then invisible, visible, etc.
[quoted text clipped - 16 lines]
Any thoughts? I'm missing something about the way control properties can be
set and tested...
 
D

Dirk Goldgar

Klatuu said:
I agree, Dirk; however, I still believe it is a good starting point.
If a person is completely unfamiliar with programming, but can write
a macro, then there is a point of relation there that can be used as
a starting point.

I agree.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top