Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Home > TechHelp > Directory > Access > Dark Mode < Install Error | Report Columns >
Dark Mode
By Richard Rost   Richard Rost on LinkedIn Email Richard Rost   8 days ago

Create Dark Mode: Toggle Light & Dark with VBA


 S  M  L  XL  FS  |  Slo  Reg  Fast  2x  |  Bookmark Join Now

In this video, we discuss how to add a basic dark mode feature to your Microsoft Access forms. I will show you a straightforward way to toggle between light and dark mode using a checkbox, make changes to text box colors automatically with a VBA loop, and adjust the form background for a more comfortable viewing experience. We will talk about handling exceptions for specific controls and highlight some important considerations when designing forms in dark mode. More advanced solutions for database-wide dark mode are also discussed.

Miles from Mesa, Arizona (a Gold Member) asks: How can I get my Microsoft Access database to switch to dark mode like the rest of Windows? I work late a lot and everything else goes dark automatically, but Access stays bright and hurts my eyes. I don't want to build and maintain two separate versions of every form, that seems like a lot of extra work. Is there an easy way to make my forms switch between light and dark?

Members

There is no extended cut, but here is the file download:

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!

Prerequisites

Links

Recommended Courses

Learn More

FREE Access Beginner Level 1
FREE Access Quick Start in 30 Minutes
Access Level 2 for just $1

Free Templates

TechHelp Free Templates
Blank Template
Contact Management
Order Entry & Invoicing
More Access Templates

Resources

Diamond Sponsors - Information on our Sponsors
Mailing List - Get emails when new videos released
Consulting - Need help with your database
Tip Jar - Your tips are graciously accepted
Merch Store - Get your swag here!

Questions?

Please feel free to post your questions or comments below or post them in the Forums.

KeywordsHow To Create Dark Mode In Microsoft Access Forms Switch Light And Dark With VBA

TechHelp Access, dark mode, Access forms, VBA dark mode, toggle dark mode, form theme colors, VBA loop controls, HexToRGB, section background color, store color settings, update form colors, customer form example, global module, ArrayList forms, save color preferences

 

 

 

Comments for Dark Mode
 
Age Subject From
7 daysDark Dark Dark ModeJeffrey Kraft

 

Start a NEW Conversation
 
Only students may post on this page. Click here for more information on how you can set up an account. If you are a student, please Log On first. Non-students may only post in the Visitor Forum.
 
Subscribe
Subscribe to Dark Mode
Get notifications when this page is updated
 
Intro In this video, we discuss how to add a basic dark mode feature to your Microsoft Access forms. I will show you a straightforward way to toggle between light and dark mode using a checkbox, make changes to text box colors automatically with a VBA loop, and adjust the form background for a more comfortable viewing experience. We will talk about handling exceptions for specific controls and highlight some important considerations when designing forms in dark mode. More advanced solutions for database-wide dark mode are also discussed.
Transcript Why is it that it seems like every other application in Microsoft Windows supports dark mode, except for Access? Welcome to another TechHelp video brought to you by AccessLearningZone.com. I'm your instructor, Richard Rost.

Today we're going to talk about adding a simple dark mode to your Microsoft Access forms. I'll show you a quick, easy way to switch between light mode and dark mode without rebuilding everything. I have a little trick to update all your text boxes automatically.

Today's question comes from Miles in Mesa, Arizona, one of my Gold members. Miles says, How can I get my Microsoft Access database to switch to dark mode like the rest of Windows? I work late a lot and everything else goes dark automatically, but Access stays bright and hurts my eyes. I don't want to build and maintain two separate versions of every form. That seems like a lot of extra work. Is there an easy way to make my form switch between light and dark?

I hear you, Miles. I myself have a very sensitive eye. I say eye because I'm blind in one eye, and my good eye isn't that great. It's very sensitive to light changes. During the day, when I have my window open and it's sunny out here in Southwest Florida, I like to have my monitor nice and bright so I can see everything. But then when the sun goes down, I like to switch everything to dark mode and you're right. Windows goes to dark mode, and it's like everything else supports dark mode. Your browser, most applications.

I have done a bunch of videos on this before, like switching your browser to dark mode, how to change your VBA editor to dark mode. In fact, I've been using this myself even during the day. I still like coding in dark mode. We've even talked about setting up different color themes for your VBA editor, but what about Access itself? What about Microsoft? What about your forms? You open up your customer form. It's nice and big and bright like this.

I'm going to show you how to do this: turn on dark mode, and then when you open up your forms, look at that. It's much darker, much more comfortable on the eye. So that's what we're going to do in today's video.

Before we get started, though, this is going to be a developer-level video. What does that mean? We're going to need some VBA. So if you've never done any VBA programming before, go watch this video. It's about 20 minutes long. It'll teach you everything you need to know to get started with VBA. It's not hard, folks. You just have to learn a little bit and you can do all kinds of cool stuff.

Make sure you understand how to do an If Then statement. We're going to do a For Each loop to loop through the text boxes on our form, so we don't want to set them all individually. You can if you want to, but you don't have to. There might be a few other things I'll point you to in a little bit, but these are the big ones. These are all free videos. They're on my YouTube channel. They're on my website. Go watch those and then come on back.

Here I am in my TechHelp free template. This is a free database. You can grab it from my website if you want to. The first thing I'm going to do is create a checkbox here, so I can decide whether my database is in dark mode or light mode.

Unfortunately, it's a lot of work to get Access to listen to Windows to say, hey, are you in dark mode or light mode? So we're just going to have to do it ourselves. We're going to trigger it with a checkbox. I'll talk more later about other options, but this is the simple way.

So we're going to go into design view. We're going to grab a checkbox control. This guy right there. Drop it right there. We're going to call it Dark Mode. That's just the label. Just make it so we can read it. Make it white.

Let's name the box itself. Come over here. Go to All. The name is going to be DarkMode. Let's go to the Data tab and set the default value to No. It should not start up in dark mode by itself. Close that. Save this and close it and reopen it. That's my main menu form. I have a button right there on my quick launch toolbar that does that. This is something you can set differently in each form if you want to, so we're just going to work on the customer form for now. I'm going to slide you over here.

What I'm going to do is say when this form opens up, we're going to look at that box and say, are you in dark mode or light mode? Go to design view. Go to the form's properties. Find the Event tab and go to the On Load event. This event runs when the form opens or loads. You can see I have my VBA editor in dark mode. Re-size it and move it over here.

We're going to say: if Forms!MainMenu!fDarkMode then we're in dark mode, so we're going to set the colors the way we want them. Let's just do a couple of controls here to make sure it's working.

CustomerID.BackColor = vbBlack
CustomerID.ForeColor = vbWhite

We'll do one more.

FirstName.BackColor = vbBlack
FirstName.ForeColor = vbWhite

Else

' We're in light mode.

Copy these, paste them down here, and reverse them.

CustomerID.BackColor = vbWhite
CustomerID.ForeColor = vbBlack
FirstName.BackColor = vbWhite
FirstName.ForeColor = vbBlack

So when the form loads, it's going to read whether we're in light mode or dark mode and adjust these two fields accordingly.

Debug, compile once in a while. Close it. Open it. Everything's normal. Close it. Switch to dark mode and open it. Here we go. We're on our way. That's our first baby step.

You could do that manually for all of these text boxes, or there must be a better way. As I rain blows upon this man, I said to myself, there must be a better way. And hence was born Festivus for the rest of us. That was the best Seinfeld episode, by the way.

We don't want to have to do this for every single text box, so we can loop through them with the For Each loop. Remember that? If you watched the other videos, you'll remember that.

We're just going to get rid of all of this stuff. I sometimes show you things this way because I want you to see the benefits of the better way. It's hard to appreciate the good way if you don't know the bad way first, the slow way, the tough way - the way that a lot of us started doing stuff.

With this method, I'm just going to say, if they're in light mode, leave the form alone. But if they're in dark mode, then we're going to flip it so all of the text boxes go from what they're at now - which we'll assume is the light mode - to white on black.

So, dark mode. We're going to say:

Dim c As Control

What's a control? All those little things on your form. Those are controls. This is a control and this is a control and this is a control. Everything on here. These buttons are controls. Checkboxes. They're all controls.

For Each c In Me.Controls

Now, there's a lot to unpack here. For each control in the collection Me.Controls. Me is the form that we're working with, which is the customer form. So, for each control in the customer form's controls collection, we're going to loop through all of them and do stuff. Then we'll say Next, which will loop to the next control. That loop will go through all of the controls on the form.

Now, what's the do stuff? If this is a text box, and only if it's a text box, we want to flip the colors. So:

If TypeOf c Is TextBox Then

That's just syntax you have to remember. TypeOf c says, I want to know what type of control this is. Is it a text box? Is it a label? Is it a button? If it's a text box, which is a special variable type, you saw it pop up with the IntelliSense there.

If it's a text box, then:

c.BackColor = vbBlack
c.ForeColor = vbWhite

If not in dark mode, just leave it as it is. Don't edit it.

Save it. Debug, compile once in a while. Come back out. Close it. Open it. Look at that. Now, turn off dark mode. There we go. It's all back to white. Every text box, including the notes, is no longer yellow. It's all gone to black.

Now, you can still override certain fields if you want to, certain controls. After this loop runs, set Notes separately or just do Notes by itself.

Notes.BackColor = vbBlue

You would want this inside the dark mode loop. So you want it in here, right there.

If we're in dark mode, then do that. When all that's finished, do this. You could do an exception in here and say:

If c.Name <> "Notes" Then

Honestly, the human eye is not going to notice this. It's easy. Just go along and set the ones you want to set separately.

Save it. Open it. Then go to dark mode. Now that guy's blue, see? You can make different colors if you want to.

One thing to keep in mind: if you do this, if you open this in dark mode and then go into design view while dark mode is active, whatever those colors are are set in the properties for the form. If you go in now and edit stuff, you might accidentally overwrite your original design colors. Just be aware of that. If you're going to make any design changes, turn dark mode off first. Now you can come in and make design mode changes. Otherwise, you come in and what is this guy? It's white on black, and those colors will be set appropriately. If you make design changes in this state, you just overwrote your light mode, so be careful doing that.

Another thing you want to be careful of is making sure you hit the Like and Subscribe button. If you're not subscribed to my videos, what are you doing here? Hit that subscribe button now. Give me a Like. It helps me, helps the channel, and helps me get my videos in front of more people. That lets me keep doing these free videos for you. I love what I do. I hope you love it too. Smash that Like.

One more thing I'm going to show you. You might also want to change the background color. This is in the Detail section property. It's actually section 0, which is what the Detail section is. There are a bunch of different sections. Right now, I only have the Detail section. There's also a Form Header/Footer, a Page Header/Footer. Those are sections 1, 2, 3, and 4. We're not going to get into all that today.

What I suggest is, unless you want to loop through and change all the labels too, which is a lot more work, just make this slightly darker so it's a little more pleasing to the eye, but still roughly the same color. Make the background color.. Now, don't use the theme colors like Accent 5, etc. I'm going to change that to a standard color that's close to what I have now. Maybe that, that's close. It's close enough.

There it is. It's a hex color. We'll talk more about hex colors in a second. Now, pick a slightly darker one like that. There you go. Remember dark mode, and you can still read the labels.

So remember what this is. Let's copy this and drop it in our Notepad. See, Notepad - a basic dark one. I have my system in dark mode right now. Hang on to that value. We're going to undo, hit Ctrl+Z, and put it back where it was. That's our light mode color.

Save. Now, in order to use hex colors, which I prefer, you need a little function that I wrote called HexToRGB. It's in my Code Vault. There it is. I'm going to copy this. I'll put it on the screen for you in a second to copy it.

We're going to switch over to our global module. If you don't have a global module, create one. We're going to paste it in right here after your declares. There's my HexToRGB function. What it does is, it takes a hex value like that guy - that's the hex color - and it converts it over into the RGB format that Access can use. Access uses RGB - Red, Green, Blue. It saves values in the properties as hex colors.

Now that we have that, we can now apply it to the section in here when our form load event runs. Watch this.

Go into our events. If dark mode is on, then we'll set the background.

Me.Section(0).BackColor = HexToRGB("XXXXXX")

(the hex color string without the pound sign)

If we're in dark mode, we're going to set the background color of section 0, which is your detail section, to this color, which is like a dark blue-ish color. Kind of blue-ish greenish.

Save it. Debug, compile once in a while. Close it. Dark mode is off. We get the nice bright color. Dark mode on, load it up, and we get our darker blue color. It's just subtly darker. We can still read the labels.

You can go through the whole thing and convert all the labels to white on black, whatever you want to do. There's lots more you can do with this. I'm just showing you the basics.

This will get you by with a form or two. You can go in here and put the code in a couple of different forms, your big ones, but it's got some limitations. What if you get a whole ton of forms and you want to switch everything at once? You want to flip them all over to dark mode, having to close them and reopen them. This method is okay, but it's very basic. You have this big background area to work with if you're using overlapping forms like I do.

If you maximize your form, you can take this guy and make it bigger. You can maximize this one, but you can't maximize that one. That's one way to do it.

If you want a cool solution, I just released Access Developer 55, where I show you how to build a proper dark mode engine for your entire database. In this database, we actually build a dark mode editor.

So you can say, I want to take a look at the customer form, open it up in design mode. Here it is. You can make your changes. Let's say you want these to be, I don't know, let's change the color here. Make it dark red. That's too bright. Let's go a little bit darker. More colors. Let's go back there. There you go. Dark red. Now, I'm going to save this as the dark mode for this form. Save it. Are you sure? Yes.

Close it. Open it up. Dark mode on. Look at that. It changed this guy to its dark mode. The background went dark. You can do that in class. The buttons all change. You can change the labels. Switch back to light mode. It works with all the forms in the database too.

Let's say you want to work on your customer list form. Open it up, this guy. Say you want these labels up here to be different. Make the labels yellow, and that is the dark mode. Close it up. Open the customer list. Switch to dark mode. Look at that.

If the customer form is already in dark mode, everybody go to light mode. Switches them all. You can edit them right here with this editor. Save light mode. Save dark mode. They'll all behave. They'll listen to you. So that's Access Developer 55. It's available on my website.

In lesson 1, we start by designing a table to store all the color settings for the forms, every section, all the controls. I show you how to generate a full list of all of your forms using an assorted ArrayList, which is really cool so everything stays nice and organized, and you have that nice drop-down box that's sorted.

In lesson 2, we build the engine that reads all those properties and saves them. We loop through all the controls like we just did and then we capture the entire form layout with just a couple of clicks. Instead of just writing them with code, we can actually read all those properties too and save that in a table.

Then we bring it all together in lesson 3 by switching between light mode and dark mode. Every open form will behave and listen to you, and all the new forms that open will also listen to the default theme that's currently active.

Finally, in part 4, we cover that background. That's a trick, and I'm not going to give away what I do, but it's cool.

If you want a powerful, professional dark mode system built right into your Access database, this class shows you how to do it. I'll put a link down below. If you have any questions, post them down below.

So there you have it. Now you have the basics of a working dark mode system for your Access forms. Again, if you have any questions, post them down below. I'll be happy to answer them for you.

That's going to do it for your TechHelp video for today. I hope you learned something. Live long and prosper, my friends. I'll see you next time.
Quiz Q1. What is the main reason the instructor suggests creating your own dark mode toggle in Access?
A. Access natively follows Windows dark mode automatically
B. It is easier than rebuilding every form in two versions
C. Access always defaults to dark mode
D. Windows cannot switch to dark mode

Q2. What control does the instructor add to the form to toggle between dark mode and light mode?
A. Combo box
B. Text box
C. Checkbox
D. Button

Q3. Where should the default value of the dark mode checkbox be set so that the form starts in light mode?
A. Yes
B. No
C. Null
D. True

Q4. What event on the form does the instructor use to initiate the color change logic?
A. OnClick
B. OnCurrent
C. OnLoad
D. OnUpdate

Q5. Why does the instructor use a For Each loop when changing text box colors?
A. To change each text box individually by hand
B. To record user preferences
C. To automate color changes for all text boxes at once
D. To edit only labels

Q6. What is checked within the loop to determine if a control is a text box before changing its colors?
A. If c.ControlType = 1
B. If TypeOf c Is TextBox
C. If c.Enabled = True
D. If c.Name = "TextBox"

Q7. If you want an exception for one control like Notes, what approach is suggested?
A. Do nothing for Notes
B. Override Notes color after the main loop
C. Delete the Notes control
D. Only loop through labels

Q8. What possible issue does the instructor warn about when making design changes while dark mode is active?
A. The database will crash
B. The Access window will freeze
C. It may overwrite your light mode design colors
D. It saves changes in another format

Q9. What property does the instructor modify to change the background color of the Detail section?
A. Section(1).BackColor
B. Header.BackColor
C. Me.Section(0).BackColor
D. Details.BackColor

Q10. Which color format does Microsoft Access use for setting colors in code?
A. HEX color code with pound sign
B. RGB values
C. CMYK values
D. Pantone colors

Q11. Why is the HexToRGB function used in this solution?
A. Access does not support RGB colors
B. It converts HEX color codes to RGB so Access can use them
C. It creates random color values for controls
D. It only allows blue colors

Q12. According to the instructor, what is a limitation of the basic dark mode technique shown?
A. It works with all forms automatically
B. It cannot be applied to text boxes
C. Each form must be handled individually
D. Only labels can be changed

Q13. How does Access Developer 55 improve upon the basic technique shown?
A. Adds sound effects
B. Provides a full dark mode engine with an editor and saves settings for all forms
C. Converts the database to Excel
D. Prevents users from switching modes

Q14. What does the instructor recommend if you want to change all label colors in dark mode?
A. Do not change labels because it is not possible
B. Use a loop to find and set label colors (even though it is more work)
C. Delete all labels
D. Only change labels manually in design view

Q15. What happens to open forms when you change themes in the advanced solution (Developer 55)?
A. Their colors do not update
B. Only text boxes change color
C. All open forms update to match the selected theme
D. You have to restart Access to see changes

Answers: 1-B; 2-C; 3-B; 4-C; 5-C; 6-B; 7-B; 8-C; 9-C; 10-B; 11-B; 12-C; 13-B; 14-B; 15-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 addresses a common question: why is it that most Microsoft Windows applications support dark mode, but Access does not? In this lesson, I will guide you through a straightforward way to add dark mode functionality to your Microsoft Access forms so you can quickly toggle between light and dark themes without needing to create or manage separate versions of your forms. I will also introduce a trick for automatically updating all your text boxes at once.

A question I often hear is how to get an Access database to switch to dark mode in sync with the rest of Windows. Users who work late at night find a bright Access screen to be uncomfortable, especially when the rest of their system seamlessly switches to a darker color palette. No one wants to redesign every form just for a dark mode effect. Fortunately, there is a much easier way to give your forms a dark mode toggle.

I completely understand the need for dark mode, as I am particularly sensitive to bright screens myself. During the day, I prefer a bright display, but once it gets dark outside, switching to a darker interface is much gentler on my eyes. Most modern applications, including browsers and many parts of Windows, now have built-in dark mode options. I've previously shown how to enable dark mode in browsers and the VBA editor, which I personally use regardless of the time of day.

However, Access forms themselves remain stubbornly bright by default. So today, I will demonstrate a practical approach you can use right now. Turning on dark mode for your form will quickly adjust the appearance so it's more comfortable to use in low-light conditions.

To follow along, you'll need to be familiar with basic VBA programming in Access. If you are new to VBA, I recommend starting with one of my introductory tutorials, which will help bring you up to speed on concepts like If Then statements and For Each loops, which are essential for today's lesson. These resources are available for free on both my YouTube channel and my website.

I start with a simple, free database template. The first step is to add a checkbox to your main form, which is used to indicate whether the database should display in dark mode or not. While it would be ideal for Access to automatically follow Windows dark mode settings, that requires more complex integration, so for now, manually flipping a checkbox is the best straightforward solution.

Adding the checkbox is simple: in design view, add the checkbox control, label it "Dark Mode," and set its name to DarkMode. Default its value to No, so the database starts in light mode unless changed.

Next, we focus on making your forms respond to the checkbox. When a form loads, it will check whether dark mode is selected and adjust the control colors accordingly. This is all handled from the form's On Load event, which runs VBA code when the form opens.

Initially, you can manually set the colors for a couple of controls in response to the mode. For instance, switch the background to black and the text to white in dark mode, and do the opposite in light mode. However, changing every control individually is not efficient, especially as your forms grow larger.

That is where VBA's For Each loop comes into play. By looping through every control on your form, your code can check if each control is a text box and adjust its appearance automatically. This saves an enormous amount of time and means you do not have to update each control by hand. The loop runs through all controls in the form's Controls collection, identifies text boxes, and then adjusts their back and fore colors according to the selected mode.

This approach also allows for exceptions. If certain controls or fields - such as a Notes field - need a unique color or appearance in dark mode, you can set those properties separately right after the loop finishes.

A word of caution: if you make design changes to your forms while dark mode is applied, you may unintentionally save the dark colors as the default for your controls. To avoid this, always turn off dark mode before you edit your form in design view.

Another appearance consideration is the form's background color, which is tied to its Detail section. You may not want to adjust every single label to be dark, but you can make the form background slightly darker to match the general look and feel of dark mode. Access allows you to set background colors using either its standard options or, for more flexibility, by specifying a hex color code. This is where a custom HexToRGB function becomes useful - it allows you to use hex colors and convert them into Access's native RGB format. You simply add the HexToRGB function to a module and call it when setting section properties.

By combining all these steps, you can create a basic dark mode system across your forms. This method will work well for a few forms. However, if you have a larger database with many forms and want to switch everything to dark mode at once, this approach may become cumbersome. For a more comprehensive solution, I recently released Access Developer 55, a class where I show you how to design a proper dark mode engine for your entire database. This engine includes editing tools for customizing and storing color settings for each form, section, and control, all managed from within Access. The class also handles synchronizing these changes so that every open and future form adheres to the selected theme.

In the class, I cover topics such as designing tables for theme settings, capturing and applying color properties across forms, and switching between themes efficiently. The last part even takes care of the tricky application background. If you need dark mode as a professional solution, this class will provide everything you need.

For now, with the steps described here, you can add a reliable, basic dark mode system to your Access forms by setting up a toggle and updating your controls and backgrounds automatically. If you have questions about these techniques or run into issues, feel free to reach out in the comments below.

For a complete video tutorial with step-by-step instructions on everything discussed here, visit my website at the link below.

Live long and prosper, my friends.
Topic List Adding a checkbox to toggle dark mode in Access forms
Naming and configuring checkbox controls for dark mode
Setting form control colors using VBA
Using the On Load event to switch modes
Manually updating text box colors in VBA
Using For Each loops to automate control updates
Checking control types with TypeOf in VBA
Excluding specific controls from color changes
Changing the Detail section background color
Applying custom hex colors with a HexToRGB function
Adding and using a global VBA module for shared functions
Storing and applying color settings for dark and light modes
Basic precautions when editing forms in dark mode
Article A lot of people have noticed that while most Windows applications now support dark mode, Microsoft Access forms remain stubbornly bright, which can be hard on the eyes, especially if you work late at night or prefer a less glaring interface. While Access does not natively support dark mode for forms, you can implement a simple, functional dark mode yourself using some basic VBA (Visual Basic for Applications). Here, I'll walk you through creating a toggle for light and dark mode on your forms, how to efficiently set colors for multiple controls, and how to make the interface easier on your eyes without having to completely redesign your database or build and maintain multiple versions of every form.

The first step is to provide a way to switch between light and dark mode. Since Access does not automatically detect your Windows dark mode setting, you need to include your own toggle. A common, easy solution is to add a simple checkbox control on your main menu form. In design view, add a checkbox and label it something clear, like "Dark Mode." Set the checkbox's name property to something descriptive such as "DarkMode," and in its Data tab, set the Default Value to No, so the database will start in light mode.

The goal is for your other forms to check this setting when they open and adjust their colors automatically. As a first test, you might update a couple of controls, such as your CustomerID and FirstName textboxes, using code in the form's On Load event. The basic VBA code for this would be:

If Forms!MainMenu!DarkMode Then
CustomerID.BackColor = vbBlack
CustomerID.ForeColor = vbWhite
FirstName.BackColor = vbBlack
FirstName.ForeColor = vbWhite
Else
CustomerID.BackColor = vbWhite
CustomerID.ForeColor = vbBlack
FirstName.BackColor = vbWhite
FirstName.ForeColor = vbBlack
End If

This code checks whether the "Dark Mode" checkbox on your main menu is checked. If it is, it sets the background (BackColor) of the CustomerID and FirstName textboxes on your form to black and their text (ForeColor) to white. If not, it sets them back to the standard white background and black text.

However, setting each textbox manually can quickly become tedious if you have many controls. A much more efficient method is to loop through all the controls on your form and apply your settings to only the textboxes. Here's how you would do that in your form's On Load event:

If Forms!MainMenu!DarkMode Then
Dim c As Control
For Each c In Me.Controls
If TypeOf c Is TextBox Then
c.BackColor = vbBlack
c.ForeColor = vbWhite
End If
Next
' Example: customize a specific control after the loop
Notes.BackColor = vbBlue
End If

This code loops through all the controls on the form (Me.Controls). For each control, if it is a TextBox, it sets the background to black and the text to white. You can add exceptions after the loop if you need specific fields to stand out or have different colors.

One important thing to watch out for is accidentally overwriting your form's design colors. If you enter design view while dark mode is active and make changes, the altered colors will become the default for your design. Always switch back to light mode before editing your form layouts to preserve your original settings.

You may also want to change the background color of the form itself to better match a dark theme. The background is controlled through the Detail section of the form. Access uses RGB color values, but you can also pick up a hex color code from your theme or color picker and convert it. To do this, you can use the following VBA function to convert a hex color string to an RGB value:

Function HexToRGB(H As String) As Long
If Left(H, 1) = "#" Then H = Right(H, Len(H) - 1)
Dim R As Integer, G As Integer, B As Integer
R = Val("&H" & Mid(H, 1, 2))
G = Val("&H" & Mid(H, 3, 2))
B = Val("&H" & Mid(H, 5, 2))
HexToRGB = RGB(R, G, B)
End Function

Paste this function into a standard module in your VBA editor. Now, in your form's On Load event, you can set the background color like this:

If Forms!MainMenu!DarkMode Then
Me.Section(0).BackColor = HexToRGB("2F3E4F")
Else
Me.Section(0).BackColor = HexToRGB("E7EAF0")
End If

Replace the hex codes with whatever color fits your preference for dark and light backgrounds.

This basic setup allows you to switch a form between light and dark modes with a single checkbox and minimal code, covering all textboxes and your background color. If you want to get more advanced, you can expand this technique to loop through and handle other control types like labels or buttons, but for most people, covering the main text controls and adjusting the general background will have the greatest visual impact with the least amount of effort.

If you are looking for a more comprehensive solution that allows you to design and save detailed color themes for all forms and controls, you may consider building a "dark mode engine" where each form's settings are stored in a table and applied dynamically, but this is more complex and beyond the basics discussed here. However, the techniques above will get you started and make your forms much easier on the eyes when working at night or in low-light environments.

With this approach, you do not need to duplicate or redesign each form. You simply add a toggle and automate the color changes with a bit of VBA. Test your forms to make sure labels and other non-textbox controls are still readable and adjust their colors if needed. Remember, always back up your database before making design changes, and turn off dark mode before entering design view to avoid overwriting your preferred light theme.

By using these simple steps, you can add a basic but effective dark mode toggle to your Microsoft Access forms, improving your working comfort and keeping your database looking modern and user-friendly.
 
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 4/30/2026 11:04:57 AM. PLT: 0s
Keywords: TechHelp Access, dark mode, Access forms, VBA dark mode, toggle dark mode, form theme colors, VBA loop controls, HexToRGB, section background color, store color settings, update form colors, customer form example, global module, ArrayList forms, save colo  PermaLink  How To Create Dark Mode In Microsoft Access Forms Switch Light And Dark With VBA