Flashing Text
By Richard Rost
5 years ago
Create Flashing Text in Forms Using a Timer Event
In this video, I'm going to teach you how to use a timer event in Microsoft Access to make text boxes in your form flash on and off and change color if they have a particular value. For example, if someone has been a customer since 1990, have them flash red. You can use the same technique to show expired registrations, overdue books, past due accounts, and more.
Paul in Shropshire, United Kingdom (a Platinum Member) asks: How can I make a text box in my form blink on and off if it has a specific value?
Members
I'll show you how to get the same effect in continuous forms, which is a lot more involved, but super cool. I'll also show you how to stop the flashing if the user clicks on any field to edit.
Silver Members and up get access to view Extended Cut videos, when available. Gold Members can download the files from class plus get access to the Code Vault. If you're not a member, Join Today!
Links
Intro to VBA: https://599cd.com/IntroVBA
Continuous Forms: https://599cd.com/Continuous
Subscribe to Flashing Text
Get notifications when this page is updated
Intro In this video, I will show you how to use a timer event in Microsoft Access to make text flash on your forms based on specific criteria, such as highlighting customers who have been with you since before a certain year. You will learn how to add a little VBA code to your form, set up the TimerInterval and On Timer events, and use conditional formatting to change text box colors. I'll also talk about how this technique works for single forms and explain why it does not work for continuous forms.Transcript Welcome to another TechHelp video brought to you by AccessLearningZone.com. I am your instructor Richard Rost.
In today's video, I'm going to show you how to use a timer event to make text flash in your Microsoft Access forms. For example, do you want to make a customer flash? If they have been a customer for a certain amount of time, like, let's say before 1990, well, there you go. Customer Since is now flashing because that guy is from 87. If I move to a different record, that guy is from 2000. He doesn't flash.
Later on in the extended cut, I'll show you how to make continuous forms flash too.
Today's question comes from Paul from Shropshire in the United Kingdom, one of my platinum members. Paul says, how can I make a text box in my form blink on and off if it has a specific value? We can do that with a timer event.
This is going to take a tiny bit of programming, but don't worry. I'll show you exactly what you have to do. First off, any of you who haven't watched my intro to VBA video, go watch that first. If you've never done any VBA programming, don't worry, it's not scary. I'll walk you through it step by step.
Now go get yourself a copy of my TechHelp free template. It's a free download on my website. You can grab it so you can follow along.
Now let's say, for example, on our customer form here, if you want to see if any customer has been in the database, they're an old-time customer. They've been a customer since, let's say, 1990. I want that to flash red so that if I open up a customer's record, one of my sales reps will say, oh wow, this is an old customer. I want to make sure to take care of them well.
You could use the same technique with anything you want. For example, if they've got a family size over a certain number, or if their credit limit is below a certain range, or whatever value you want. I'm just going to show you how to do it with Customer Since.
Let's go into Design View. Open up the form's properties. Go to the Event tab, scroll down toward the bottom here. You'll find something called TimerInterval and On Timer. The TimerInterval means every so many milliseconds, this timer event is going to kick off. It's set to zero, meaning your form doesn't have a timer.
This is in milliseconds. If I want this to run every one second, I have to change that to 1,000. Remember, it's milliseconds. What's going to happen every second is whatever I put in this On Timer event. Go to the build event, pick the Code Builder, which you know about if you've watched my intro to VBA.
Now, I'm inside the Form_Timer. What I'm going to say in here is if Customer Since is less than 1/1/1990. Remember, we have to put dates inside of those little hashtags, those octothorpes, to indicate to Access it's a date. Then do some stuff. End If.
What's the stuff? In here is where I'm going to handle my flashing. I'm going to do that just by changing the background color of that text box. I'm going to say if the text box is already white, then change it to red. If it's not, then change it back to white.
If CustomerSince.BackColor equals vbWhite, then change it to red: CustomerSince.BackColor equals vbRed. Let's change the foreground color too: CustomerSince.ForeColor equals vbWhite. We'll do white text on a red background.
Otherwise, let's set it equal to what it should be. Let's say CustomerSince.BackColor equals vbWhite, and then CustomerSince.ForeColor equals vbBlack, black text on a white background.
Every second, this is going to run. If Customer Since is less than 1/1/1990, then if the back color is white, make it red. Otherwise, set it back to white. That'll run every second.
This shouldn't interfere with anything else that's going on in your form. You can still type, you can still work. If you've got other sophisticated VBA running in the background, you might have issues with timer events, but only with really sophisticated events. For most people, for the average user, don't worry about it.
As long as this form is open, the timer event will run. When you close the form, it stops running.
Let's save it. Control S, close it up, open up the customer form. This customer is 1/1/1994. Let's scroll through the customers here: in 2003, 1999, 87. Oh, look at that. It's flashing in that party. Let's move to the next one, 2000, and it stops flashing. That one's blank, so that doesn't run.
Let's go back to the 87 one. I want to show you something that can happen here. Now, be very careful. Watch this. If it's red and I leave it, right now, see, it's stuck on the red. See? So we have to have one more tiny event in there, design view. We have to go to the On Current event also.
On Current happens when you move from record to record or when the form opens. So right here, all we're going to say is just set it back to black and white, just to make sure that we don't get stuck with that conditional formatting on.
So, whenever we move to a new record, we'll automatically get black on white background, and then the timer event will kick in and change it if necessary.
Let's go back and test that now. Let's see. Ready? Let's go to our 87. There we go. I'm going to try and leave it on red. And go. And it turned off automatically.
So you can use this technique for anything you want. Any of those fields you want to change. If you want to have something flash, change colors, do whatever you want. That's how you do it with a little timer event.
Unfortunately, this only works with single forms. You can't do this with a continuous form. So if you've got a list of customers, it won't work. Let me show you.
Let's go to the customer list. This is a continuous form. If you've never made a continuous form before, go watch my video on continuous forms. I'll put a link down below.
If I add, let's add that field to this form. Add existing fields. There's pretty much Customer Since. Let's bring it in, drop it over here, chop off that label, slide it up here.
Let's try the same technique. While I have my code window open, I'm just going to slide over here and copy this to my clipboard. Copy all that so I don't have to type it all in again. Same field, though.
Let's go to this form's timer event, open up events, scroll down, set the timer interval to 1,000 milliseconds. Go to timer, paste all that code in there. Should work. Same exact stuff.
We'll need the current event too. Let's go to Form_Current right there. Let's put that current event, which is just this stuff, copy and paste. Slide to the left. Let's save that.
So, let's see what happens. Customer list. That looks fine. Nothing's running though. Click down here. Click on Picard. Oh, look at that. Now it's running for everybody.
Why is that? That's because in a continuous form, whenever you make a change to a field's property, it affects all of them. You can't just change one thing. If I set a field to background color red, all of them on the form change to background red.
There is a way to get this to work, though. I will cover that in the extended cut for the members.
Want to learn more? Like I said, that technique only works in a single form. If you want the text in a continuous form to flash, it's a little more in depth, a little more complicated, but I will show you in my extended cut.
Here's what we got right now in the regular version. Let's go take a peek at the customer list. Look at that. Isn't that cute? Isn't that cool?
When you click on something to edit it, it will stop the flashing so it doesn't interfere. Sometimes, a little more complicated code can interfere with the editing of data, so when you click on one of these fields in here to edit it, it will stay off until you tab back to the ID field and then it will start flashing again. That's covered in the extended cut.
As a reminder, Silver members and up get access to all of my extended cut videos and Gold members can actually download these databases from my website.
We've got well over 100 TechHelp videos now and almost 100 extended cuts, so there is tons and tons of extra material for you to watch.
How do you become a member? Click the Join button below the video. After you click the Join button, you'll see a list of all the different types of membership levels that are available. Silver members and up will get access to all of the extended cut TechHelp videos, live video and chat sessions, and more.
Gold members get access to a download folder containing all the sample databases that I build in my TechHelp videos, plus my Code Vault where I keep tons of different functions that I use.
Platinum members get all the previous perks plus access to my full beginner courses and some of my expert courses. These are the full length courses found on my website and not just for Access. I also teach Word, Excel, Visual Basic, ASP and lots more.
But don't worry, these free TechHelp videos are going to keep coming. As long as you keep watching them, I'll keep making more.
If you liked this video, please give me a thumbs up and feel free to post any comments that you have. I do read them all. Make sure you subscribe to my channel, which is completely free, and click the bell icon and select All to receive notifications when new videos are posted.
Click on the Show More link below the video to find additional resources and links. You'll see a list of other videos, additional information related to the current topic, free lessons, and lots more.
YouTube no longer sends out email notifications when new videos are posted, so if you'd like to get an email every time I post a new video, click on the link to join my mailing list.
If you have not yet tried my free Access Level 1 course, check it out now. It covers all the basics of building databases with Access. It's over three hours long. You can find it on my website or on my YouTube channel. If you like Level 1, Level 2 is just one dollar. It's also free for all members of my YouTube channel at any level.
Want to have your question answered in a video just like this one? Visit my TechHelp page and you can send me your question there.
Click here to watch my free Access Beginner Level 1 course, more of my TechHelp videos, or to subscribe to my channel.
Thanks for watching this video from AccessLearningZone.com.Quiz Q1. What is the primary purpose of the timer event in Microsoft Access forms as demonstrated in the video? A. To automatically save customer data B. To make text flash based on a specific condition C. To print reports every hour D. To sort records alphabetically
Q2. Which property must be set on the form to enable the timer event to run? A. DefaultView B. AllowEdits C. TimerInterval D. RecordSource
Q3. In the example shown, what field condition causes the text box to flash? A. When the customer's credit limit is above a certain value B. When the customer is added today C. When the customer has been with the company since before 1990 D. When the customer's email address is missing
Q4. What is the correct TimerInterval value to make the timer event run every one second? A. 100 B. 10,000 C. 1 D. 1,000
Q5. What is the purpose of using the On Current event in this solution? A. To stop the timer event when the form is closed B. To reset the text box formatting when moving between records C. To delete old records D. To requery the data source
Q6. When using the timer event to flash a text box, which property is changed to produce the flashing effect? A. The text box's width B. The text box's ForeColor and BackColor C. The form's caption D. The record's primary key
Q7. Why does the timer-based flashing technique not work correctly in a continuous form? A. Continuous forms do not support code in events B. Changing a field property in a continuous form affects all visible records simultaneously C. Continuous forms cannot display color changes D. The timer event is not available in continuous forms
Q8. According to the video, what happens if you edit a flashing field in the form? A. The form closes automatically B. The field continues to flash while editing C. The flashing stops until focus is moved away D. The flashing speeds up
Q9. For which kind of form does the demonstrated timer technique work as expected? A. Report view only B. Single forms only C. Continuous forms only D. Table datasheets only
Q10. What should be added to the On Current event to avoid the flashing field being left in the 'on' (red) state when moving between records? A. Code to hide the form B. Code to requery the subform C. Code to set the text box colors back to default (black on white) D. Code to show a message box
Answers: 1-B; 2-C; 3-C; 4-D; 5-B; 6-B; 7-B; 8-C; 9-B; 10-C
DISCLAIMER: Quiz questions are AI generated. If you find any that are wrong, don't make sense, or aren't related to the video topic at hand, then please post a comment and let me know. Thanks.Summary Today's video from Access Learning Zone covers how to use a timer event in Microsoft Access to make text flash on your forms. Specifically, I will walk you through how you can have something like a "Customer Since" field flash if certain conditions are met. For example, you might want it to draw attention to customers who have been with you since before 1990. When viewing a record that meets this condition, that field will flash, alerting your staff to the customer's status. If you move to a record where the condition is not met, nothing happens.
This question actually comes from one of my members who asked about making a text box blink if it has a particular value. The best way to accomplish this in Access is to use a timer event, and while it will require a little bit of programming in VBA, I will make sure you are comfortable every step of the way. If you are completely new to VBA, I recommend watching my introductory video on VBA programming first. That will help you get familiar with the basics before proceeding.
To follow along, you can download my free TechHelp template from my website. This will let you practice with the same examples I use in the lesson.
Let's consider a customer form where you want to highlight "old-time" customers, such as anyone who has been in the database since before 1990. I want the "Customer Since" value to flash red for these records, so sales reps are immediately aware. Of course, you could use the same method for any field or condition you like, such as highlighting family size over a certain number, a low credit limit, or just about any value that's important to your business.
The key is setting up your form to use the timer. In Design View, you'll find a property called "Timer Interval," measured in milliseconds. By setting this to 1000, you cause the timer event to fire every second. Whatever you place in the timer event's code will repeat at that interval.
Inside the event, you simply check your condition. In my example, I check if "Customer Since" is earlier than 1990. If so, the code toggles that text box's background and foreground colors between red and white, making it flash. Every second, the code sees the current color and switches it to the opposite.
This method does not interfere with normal use of your form. You can still edit, add, and view records as usual. Unless you have extremely complicated processes running in your form, the timer event will function smoothly for the average user.
An important point to consider: when moving between records, you may find the field gets stuck in its last color. To prevent this, you should reset the field's formatting in the form's On Current event. This way, whenever you load a new record or open the form, the control is restored to a default color, and the flashing will only happen if the condition is met.
You can use this technique for virtually any scenario where you want to draw attention to a record or field via color or flashing, triggered by whatever condition is relevant to you.
It's important to note that this method will only work with single forms. If you try it in a continuous form (which displays multiple records at once, like a list), changing a field's color changes it for all records being displayed. This means you cannot selectively make one field in a continuous form flash without affecting the others. If you want this function to work for continuous forms, it requires a more complex solution, which I cover in detail in the extended cut available to members.
As an example, in the lesson, I show that if you try this flashing technique on a customer list (a continuous form), the background color setting will apply to all displayed records at once, so every record will flash rather than just the intended one. I also describe in the extended cut how you can work around this limitation and get individual fields to flash in continuous forms.
If you are interested in more advanced features like this or want to access the downloads, sample databases, and my in-depth extended cut videos, consider becoming a member. Silver members get access to all extended cuts, live chat sessions, and more. Gold and Platinum members can also download all of my databases and access complete beginner and expert courses on Access, as well as other programs like Word, Excel, and more.
You can find plenty of other free resources, including my beginner Access course, which is over three hours long and covers the basics of building databases. This course is also available on my website and YouTube channel, and upgrading to Level 2 is only a dollar or free for members.
To have your questions answered in a future video, visit my TechHelp page and submit your topic. For additional links, resources, and free lessons related to this and other topics, visit the Show More section below the video.
A complete video tutorial with step-by-step instructions on everything discussed here can be found on my website at the link below. Live long and prosper, my friends.Topic List Using a timer event to make text flash in Access forms Setting up the TimerInterval property for forms Adding VBA code to the On Timer event Checking field values to trigger conditional flashing Changing text box background and foreground colors in VBA Resetting field colors with the On Current event Ensuring flashing only occurs on specific records Limitations when using this technique in continuous forms
|