How do I run VBA code when form opens?
There are probably several ways people do it, and some may say “He’s not doing it right. It’s done this way…”
Good for you. This is the way I do it now, and it has worked well for me.
1. Find the form you want to run code when you open the form. (refer to the video below)
2. Go to the Events tab, “On Open” (the “code block” is generated automatically for you)
3. Click the triple dots “…”

4. The the VBA window will launch into the “Sub Form_Open()”

5. Type Msgbox “The form is now opened”

6. Close the form and save you changes.
7. Open the form and you will see your message box.

I’ll have a video of how it’s done under this:
Congratulations, you have just programmed the open event of your form.
How to Delete Blank Rows in Excel Using VBA (Step-by-Step Guide)
How to Delete Blank Rows in Excel Using VBA (Step-by-Step Guide) When you work with large datasets in Excel, it’s common to end up with thousands of blank rows scattered throughout your worksheet. Maybe your data came from a mainframe export, a CSV download, or a legacy system that doesn’t format properly. Deleting all those […]
Learn Access VBA: Understand Tables, Queries, Forms, and Reports
Learn Access VBA: From Zero to Database Hero If you’ve ever opened Microsoft Access and wondered how all the pieces fit together — tables, queries, forms, and reports — this tutorial is made for you. In just a few minutes, you’ll understand how Access works behind the scenes and see how VBA (Visual Basic for […]
How To Make An Access Form Time Picker
Here is a relatively easy way to select times for your time entry text boxes. It’s a reusable form that allows you to pick a time from an Access form. There are probably different ways to do this but here is the way I would do it. On the form that has the time fields, […]
How to pick a file to load In VBA
How to Pick a File in VBA: FileDialog & GetOpenFilename Explained When building Excel VBA applications, you’ll often need to let users pick a file to load in VBA. Instead of hard-coding file paths, you can use built-in dialogs that make file selection easy and user-friendly. VBA offers two main approaches: FileDialog object (flexible, customizable) […]
Support these sponsors: