All code samples are free to download and free to use in your own applications providing any copyright notices are included without any changes made.
All code will work in both 32-bit and 64-bit Access unless stated otherwise.
We do not give the same support to these code samples as for our commercial programs. However, please contact us if you have questions or suggestions for improvements.
Access / Office 365 / Windows Version Check
Version 2.55 Last updated: 25 Nov 2021
This is a simple utility to check the following:
a) Windows version & bitness (32/64-bit)
b) Access version & bitness
c) Whether Office 365 is installed
More Details
Add colour to queries, combos & listboxes
Last updated: 14 Feb 2018
This article explains how colour formatting can be used for formatting text, number and date fields in queries and tables.
A similar approach can be used for text boxes, combo boxes and list boxes in forms
More Details
Age Calculation
Last updated: 18 Apr 2022
This article gives various functions for calculating age in years, years and months or years, months and days
More Details
Application.UserControl property
Last updated: 29 Nov 2019
This shows how the UserControl property can be used to restrict how an application can be opened. Just one line of code is required in the Form_Load event of the startup form or in an autoexec macro.
Two examples are provided each containing a Starter app and a Main app:
a) BlockDBOpenDirect
- the Main app can be opened via the Starter app but cannot be run directly.
b) BlockDBRemoteAccess
- the Main app can be run directly but cannot be opened remotely using automation
Possible uses include using method b) in conjunction with other security measures such as disabling the shift bypass to help prevent hacking using automation.
More Details
Check Procedure Exists
Last updated: 4 Jan 2019
This article contains code to check if a procedure exists in an Access project
More Details
Close All VBE Windows
Last updated: 18 Apr 2017
This is a simple function to close all VBE windows. This is very useful when so many windows are left open you can't find anything. It also significantly speeds up loading the VBE editor if it doesn't need to load lots of unwanted 'legacy' windows
More Details
Create Index on linked SQL View
Last updated: 25 Nov 2017
This article explains how to add an index to a linked SQL Server view so that the data can be edited in Access
More Details
Database Statistics
Last updated: 30 Jan 2022
This includes a procedureGetDatabaseStatistics which examines all tables, forms, reports, macros and modules in a project and produces statistics about the number of fields, controls, VBA functions, lines of code etc.
The results are saved to the VBE immediate window and to a message box
More Details
Detailed System Info
Last updated: 20 Feb 2022
This uses Windows Management Instrumenation (WMI) to obtain detailed information about your computer system / processor / BIOS / each hard drive or logical disk.
More Details
Easter Calculator
Last updated: 7 Jul 2017
This is a 3 line function which calculates Easter Sunday for any year up to 2368.
It is adapted from code originally done for Excel by Chip Pearson
More Details
Edit Linked Excel Data in Access
Last updated: 26 Feb 2022
Linked Excel files have been read only in Access since 2002 when Microsoft removed the ability to edit them directly.
Normally developers either use automation or import the file, edit then export back to Excel.
However, there is a much better method which is not widely known about. This article shows how linked Excel files can be directly edited in Access. New records can also be added. This approach relies on setting the IMEX value = 0
More Details
Fill down in tables, queries & forms
Last updated: 31 Jan 2022
This explains a simple method of copying field values from one record to the next
More Details
Fix Google maps display issues in Access web browser control
Last updated: 26 Mar 2022
This article explains how to fix Google maps display issues in Access web browser controls based on Internet Explorer
More Details
Fix shrunken navigation pane
Last updated: 11 May 2018
Sometimes the width of the navigation pane can become so small that it cannot be expanded by standard methods.
This article describes 3 methods of solving the issue if it happens to you
More Details
Formatted Message Box
Last updated: 3 Jul 2017
This provides a simple method of using BOLD text in a standard message box
More Details
Get Computer Name
Last updated: 8 Dec 2018
This describes 3 different methods of getting the current computer name using VBA and compares the effectiveness of each method
More Details
Get list of VBA References & locations
Last updated: 5 Nov 2017
This article describes two different routines giving a list of VBA references & their locations.
This can be useful if you need to create a fresh copy of your database or deal with reference issues on a client machine. In such cases, it can be difficult to identify where certain references are located and the small size of the reference window doesn't help.
More Details
Get User Full Name
Last updated: 11 Mar 2022
This shows how Windows Management Instrumentation (WMI) can be used to get the full name of the user belonging to the network login profile.
More Details
Get User Name
Last updated: 12 Sept 2018
This describes 3 different methods of getting the current user name using VBA and compares the effectiveness of each method
More Details
Get Value in Previous Record
Version 2.0 Last updated: 3 Dec 2018
This shows a method for calculating the difference between values in the current record with those in the previous record. For example, this approach can be used for calculating energy consumption between meter readings.
More Details
Group Page Numbering in Report
Last updated: 21 Dec 2017
This article explains how you can reset the report page numbering at the start of each new group
More Details
Hide Access Splash Screen
Last updated: 25 Feb 2022
This article explains how to remove the splash screen that normally appears when you open any Access application
More Details
Linked No Tables
Version 2.0 Last updated: 6 Feb 2019
This DEMO application shows a method of running a split database where the connection strings cannot be viewed by end users
The front end (FE) database has no linked tables.
The FE file has 2 forms and 1 report none which have a permanent record source
The backend (BE) contains 1 ‘deep hidden’ table though it would work equally well with a standard table.
The record source for each FE object is set automatically to the BE table when the object is opened. It is cleared again when the object is closed
More Details
List Access Error Codes
Last updated: 3 Jun 2018
This is a procedure to create a complete list of Access error codes and descriptions
More Details
Manage Nav Pane / Ribbon / Taskbar / Application Window
Last updated: 25 Oct 2017
This article explains how to manage parts of the application interface using VBA:
a) Navigation Pane - hide / mimimise / maximise
b) Ribbon - hide / minimise / maximise
c) Taskbar - hide / show
d) Application window - hide / show
More Details
Masked Input Box
Last updated: 28 Aug 2018
This is an updated version of the masked input box code originally written by Daniel Klann in 2003 for 32-bit Access only.
This updated version will work in both 32-bit and 64-bit Access
More Details
Negative Total Pages on Report
Last updated: 17 Jan 2019
If you have a VERY large report with more than the integer limit of 32767 pages, Access will display the total pages as a negative number
For example: Page 1 of -15440 pages
This article explains how to deal with that situation if it arises
More Details
Prevent Copy & Paste in Forms
Last updated: 29 Oct 2017
This article explains how to prevent users copying and pasting text in forms
More Details
Progress Bar
Last updated: 3 Dec 2020
This is a simple but effective progress bar for use in Access forms
More Details
Rank Order in Queries
Last updated: 9 Jun 2018
This shows one way of creating rank orders in Access queries using the Serialize function
More Details
Remove core Windows 'modern' apps
Last updated: 16 Jun 2018
Certain core Windows modern apps CANNOT be removed using Add/Remove programs.
However if you have a problem, these cannot be installed from the Windows Store as they are already installed! CATCH-22!!!
This article explains how to remove these core Windows modern apps using Powershell.
More Details
Set Character Limit in Long Text (Memo) Fields
Last updated: 26 Mar 2022
This article explains how the number of characters in long text fields can be limited using VBA code. It also includes code to check the spelling of entered text. This is particularly useful if text entry is done using the Windows dictation tool.
More Details
'UPEND' or 'UPSERT' Query
Last updated: 18 Sept 2018
A very common database task is to both append new records to a table and update existing records. The standard approach is to use an APPEND query and an UPDATE query.
This article explains how to combine both of these into a single UPEND (AKA UPSERT) query.
More Details
View All Database Objects
Version 2.2 Last updated: 26 Oct 2020
This item allows you to view all objects in a database.
The list of database objects is obtained from the hidden system table MSysObjects.
It is updated automatically as objects are added to or removed from the database.
More Details
View Form Code
Last updated: 11 Mar 2022
This article describes different methods of viewing the VBA code for a form or individual procedure
More Details
Return To Home Page
Return To Top
Complete List of Code Samples