logo
search
VBA & Macro Problems

How to Stop an Access Form Timer After 30 Days Using VBA

Camila MilosovichCamila Milosovich Oct 15, 2026 870 views

Question details

The user wants to use VBA to make a specific date field flash on a form for 30 days, after which the form timer should automatically stop.

How to Stop an Access Form Timer After 30 Days
Product
Microsoft Access
Device & OS
not provided
Scenario
Creating a visual alert on a database form where a date field alternates colors to grab attention but needs to automatically stop flashing after a 30-day period.
Observed behavior
The form utilizes a timer to alternate the background and foreground colors of the target field. Once 30 days have passed from the specified date, the timer interval must be set to 0 to disable the flashing effect.
Before you start

Ensure you have a backup of your Access database before modifying the form's VBA code, and verify the name of the date text box control you want to manipulate.

Solution 1Recommended

Use VBA DateAdd Function to Disable the Timer

Implement a VBA script on the form's Timer event that evaluates the date difference and sets the TimerInterval to 0 once the 30 days have elapsed.

This method evaluates whether 30 days have passed since the date logged in your specified field. As long as the current date is within that 30-day window, the code alternates the background and foreground colors of the field to create a flashing effect. Once the period expires, it disables the form timer entirely.

1
Set the initial form Timer Interval

Open your Microsoft Access database in Design View for the specific form. Navigate to the Property Sheet, select 'Form' from the drop-down, and set the 'Timer Interval' to your preferred flashing speed (e.g., 500 for a half-second interval).

2
Open the VBA Code Builder

In the Property Sheet under the Event tab, click the ellipsis (...) next to 'On Timer'. Choose 'Code Builder' to open the VBA editor for the Form_Timer event.

3
Insert the Date Verification Code

Add a conditional statement to check if the field is not null and if the date is within the 30-day window. Use: If Not IsNull(Me.CANDATE) Then If DateAdd("d", 30, Me.CANDATE) > Date() Then

4
Add Color Alternating Logic

Inside the active date condition, add logic to switch colors. For example: If Me.CANDATE.BackColor = vbWhite Then Me.CANDATE.BackColor = vbRed Else Me.CANDATE.BackColor = vbWhite.

5
Disable the Timer Upon Expiration

Add an Else statement for the date check to turn off the timer when the 30 days have passed. Include: Else Me.TimerInterval = 0 End If.

Use VBA DateAdd Function to Disable the Timer
Tip: Make sure to replace 'CANDATE' in the VBA code snippet with the actual Name property of your date text box control.
Free Microsoft Office alternative

Looking for a Lightweight Office Suite?

While Microsoft Access handles complex databases, for your everyday spreadsheet, document, and presentation tasks, WPS Office provides a fully compatible, free, and lightweight alternative to Microsoft Office. It flawlessly handles Excel macros and VBA scripts without the heavy resource requirements.

  1. 1. Download WPS Office: Visit the official WPS website and download the free installation package for your operating system.
  2. 2. Install the Software: Run the installer and follow the simple on-screen instructions to set up WPS Office on your computer.
  3. 3. Open Your Office Files: Launch WPS Spreadsheet, Writer, or Presentation and open your existing Microsoft Office files with perfect formatting retention.
Highly compatible with Microsoft Office formats including DOCX, XLSX, and PPTXBuilt-in support for advanced Excel-style macros and VBA in WPS SpreadsheetLightweight design that runs smoothly on almost all devicesFree to download with a familiar and intuitive user interface
microsoft office alternative - wps office

Frequently Asked Questions

What unit of measurement does the Access TimerInterval use?

In Microsoft Access, the TimerInterval property is measured in milliseconds. Setting the interval to 1000 will trigger the Form_Timer event once every 1 second.

Why isn't my form timer triggering the VBA code?

Ensure that the form's TimerInterval property is initially set to a value greater than 0 in the Property Sheet, and verify that your VBA code is placed specifically inside the Form_Timer() event procedure.

Can I use this VBA method to check for a different number of days?

Yes. You can easily modify the DateAdd function in the VBA code by changing the numeric argument (e.g., changing 30 to 60) to set a different expiration period for the flashing alert.