Code Snippets
+ Tips
Tips To Help You With Microsoft Access
Determine if a File is Open
Use this VBA function to determine if a file is already open. For example, before attempting to import an Excel file into a Microsoft Access database, you can call this function, and if the file is open, notify the user that they need to close the Excel file first. ...
Replace Fonts in a Microsoft Access Database
In a recent database project, the Courier font was no longer being recognized, and Microsoft Access was using the MS Sans Serif font and the System font to replace it. I used these VBA functions to replace MS Sans Serif and System with Courier (Detail) throughout the...
Use VBA to Calculate Age
This VBA function uses the DateDiff() and DateSerial() functions to calculate an age in years. For example, if you would like to show the current age of an employee on a form or a report, you can call the function in the Control Source of a text box, and pass the...
Find a Record in a Microsoft Access Form
Syncing one Microsoft Access form with another is made simple with this VBA function. It finds and moves to a record in a form by looking for a value in a specific field that is in the form’s recordset. For example, this would allow you to click on an employee ID in...
Use SaveAsText to Edit a Macro in Microsoft Access
When you have a Microsoft Access database with a lot of macros, it can be a challenge to find all the places where an object is being used in the macros and replace it with a different object. These VBA functions will allow you to replace a value in a particular...
Delete Attachments from a Microsoft Access Table
You may store file attachments in Microsoft Access by utilizing the Attachment field in table design. Unlike other field types, the Value property of the field is actually a recordset of the attached files. These VBA functions allow you to delete the attachments by...
Determine the Default Email Client
Microsoft Access can automate sending emails, setting appointments, etc. in Microsoft Outlook. However, if the user has a different email client specified as their default, you may need to make adjustments in your logic. This VBA function returns the name, or...
Send the Values of Microsoft Access Query Properties to a Table
Trying to find out which queries in your Microsoft Access database are pass-through queries, which ones have parameters, or which ones have crosstab headings specified? This VBA function sends the values of 42 different query properties and attributes to a table. It...
Save an Excel File as a Tab Delimited Text File
Microsoft Access provides several ways to import the data from an Excel file. Sometimes, the way the Excel data was entered can create problems during the import. This VBA function will allow you to automatically save an Excel file to a tab delimited text file. ...
Use VBA to Close all Microsoft Access Objects of a Particular Type
Pass an object type to this VBA function, and it will automatically close all of the open objects of that type. It loops through an object collection, like AllForms, and examines the IsLoaded property of each AccessObject in the collection. For example, if you are...
Create a Folder if it is Missing
This VBA function uses the FileSystemObject to create a folder if it does not already exist. If the folder is several subfolders deep, it creates all of the subfolders as well. As an example, you could call this function to create an employee folder on the network...
Copy a Set of Folders from a Master Folder to Other Folders
This VBA function copies a set of subfolders from a master folder, and then adds those subfolders to all of the folders in a different location. For example, let’s say that you already have a folder for each employee under the Employees folder on the network. But...
Set and Retrieve User Settings in Microsoft Access
Microsoft Access database systems are structured so that each user has a dedicated front-end file installed on their computer. The front-end is the user interface for the system: data entry forms, logic, and reports. Along with reducing the opportunity for data...
Use VBA to Combine Multiple Excel Files into One Workbook
Microsoft Access to Microsoft Excel Microsoft Access provides several ways to export tables and queries to Microsoft Excel. Each object that gets exported creates one Excel file with a single worksheet. You can use the VBA function below to combine multiple files...
Change a Microsoft Access Color Value to a Number
Many controls used on a Microsoft Access form or report have color properties, like Back Color or Fore Color. Selecting a color value is easy – just use the color picker in the Property Sheet for the control. When you choose a custom color, the color value that...
Limitations of a Microsoft Access Database System
Microsoft Access is a powerful database platform, and perfect for many small and mid-size business applications. However, it does have some limitations. Below is a list of five things to consider before investing in a Microsoft Access system. There is a learning...
When to Use a Microsoft Access Database System
Microsoft Access does a masterful job at managing business data. Extra Mile Data has worked with scores of different companies across dozens of industries that use Microsoft Access to save time and make money. Below are five selling points for using a Microsoft...
Count Selected Check Boxes on a Microsoft Access Form
The VBA functions below can be used to count, and to clear, all of the selected check box controls on a Microsoft Access form. For example, a criteria form may present dozens of report options using check boxes, and each selected checkbox will open a report when a...
Build a Microsoft Access LIKE Statement from Lists
Microsoft Access SQL provides a Like operator that can be used in queries to compare values to a pattern. For example, let’s say that you have an Employee table with FirstName and Middle fields, and you would like to find all records that have “Bob” or “Robert” (or...
Change All Blanks in a Microsoft Access Table to Null
Microsoft Excel data is rarely managed to prevent a user from leaving blanks (just spaces or a zero-length string) in worksheet cells. When the Excel worksheet is imported into a Microsoft Access table, the blanks come with it. Those blanks may cause problems later...
Making Microsoft Access Work
No matter what your MS Access needs are, Carl can provide live help to make sure you get the solution you need.