Uploaded October 2026 | Updated November 2026, 5 days ago
In this lesson, we will walk through creating a saved QueryDef in Microsoft Access using VBA. You will learn how CreateQueryDef saves SQL as a named query, why QueryDefs are useful when different users need different selected fields or query structures, and how QueryDefs differ from parameter queries that only change values.
Marissa from Albuquerque, New Mexico (a Platinum Member) asks Different people need different columns in my Access customer list. One person wants names and email addresses, while another wants names and phone numbers. I don't want to maintain a separate query for every possible combination. Can my database create the saved query someone needs when they make their selection?
Silver Members & up get access to an Extended Cut of this video. In the extended cut, we will learn how to create and replace saved queries with VBA, use temporary in-memory QueryDefs, and use parameterized queries. I will also show you how to display query results on a form, dynamically choose fields to display, and combine multiple fields into one using an SQL alias.
MEMBERS-ONLY EXTENDED CUT VIDEO:
youtu.be/jb7zMwurCc8
CHAPTERS:
00:00 Introduction
02:25 Understanding QueryDefs
03:19 Prerequisites
03:42 Creating a Saved Query with VBA
05:54 When to Use Dynamic Queries
07:18 QueryDefs vs. Parameter Queries
08:17 Conclusion
BECOME A MEMBER:
YouTube: youtube.com/channel/UCl7-jJie4ifOVK87FINIuDg/join
or My Site: 599cd.com/THMember
LEARN MORE:
QueryDefs: 599cd.com/QueryDefs
PREREQUISITES:
Intro to VBA: 599cd.com/IntroVBA
SQL with Access: 599cd.com/SQLwithAccess
Status Box: 599cd.com/Status
LINKS:
Custom List Box: 599cd.com/CustomListBox
Parameter Query: 599cd.com/Parameter
Convert Query SQL to VBA: 599cd.com/1474
Record Source: 599cd.com/RecordSource
RECOMMENDED COURSES:
QueryDefs in Access Developer 37: 599cd.com/ACD37
Dynamic SQL Filtering in Access Developer 26: 599cd.com/ACD26L
Query Building in Access Developer 19: 599cd.com/ACD19
SQL Basics in Access Expert 3: 599cd.com/AC10X3
FREE TEMPLATE DOWNLOADS:
TechHelp Free Templates: 599cd.com/THFree
Blank Template: 599cd.com/Blank
Contact Management: 599cd.com/Contacts
Order Entry & Invoicing: 599cd.com/Invoicing
More Access Templates: 599cd.com/AccessTemplates
DIAMOND SPONSORS:
More info on our Sponsors: 599cd.com/DiamondSponsors
ADDITIONAL RESOURCES:
FREE Access Beginner Level 1: 599cd.com/Free1
How to Use Access in 30 Minutes: 599cd.com/30Minutes
$1 Access Level 2: 599cd.com/1Dollar
Donate to my Tip Jar: 599cd.com/TipJar
Merch Store! Get your swag here: 599cd.com/Merch
Get on my Mailing List: 599cd.com/YTML
Contact Me: 599cd.com/Contact
TechHelp: 599cd.com/TechHelp
Consulting Help: 599cd.com/DevNet
Twitter: twitter.com/LearningAccess
en.wikipedia.org/wiki/Microsoft_Access
products.office.com/en-us/access
microsoft.com/en-us/microsoft-365/blog/access
KEYWORDS:
TechHelp, Access 2016, Access 2019, Access 2021, Access 2024, Access 365, Microsoft Access, MS Access, MS Access Tutorial, #msaccess, #microsoftaccess, #help, #howto, #tutorial, #learn, #lesson, #training, #database, DAO QueryDef, CreateQueryDef VBA, Access QueryDef, create saved query with VBA, dynamic SQL query, CurrentDb.CreateQueryDef, dynamic SELECT fields, VBA query builder, temporary QueryDef, parameter queries, replace saved query, SQL field picker
QUESTIONS:
Please feel free to post your questions or comments below. Thanks.
Live long, and prosper.
In this lesson, we will walk through creating a saved QueryDef in Microsoft Access using VBA. You will learn how CreateQueryDef saves SQL as a named query, why QueryDefs are useful when different users need different selected fields or query structures, and how QueryDefs differ from parameter queries that only change values.
Marissa from Albuquerque, New Mexico (a Platinum Member) asks Different people need different columns in my Access customer list. One person wants names and email addresses, while another wants names and phone numbers. I don't want to maintain a separate query for every possible combination. Can my database create the saved query someone needs when they make their selection?
Silver Members & up get access to an Extended Cut of this video. In the extended cut, we will learn how to create and replace saved queries with VBA, use temporary in-memory QueryDefs, and use parameterized queries. I will also show you how to display query results on a form, dynamically choose fields to display, and combine multiple fields into one using an SQL alias.
MEMBERS-ONLY EXTENDED CUT VIDEO:
youtu.be/jb7zMwurCc8
CHAPTERS:
00:00 Introduction
02:25 Understanding QueryDefs
03:19 Prerequisites
03:42 Creating a Saved Query with VBA
05:54 When to Use Dynamic Queries
07:18 QueryDefs vs. Parameter Queries
08:17 Conclusion
BECOME A MEMBER:
YouTube: youtube.com/channel/UCl7-jJie4ifOVK87FINIuDg/join
or My Site: 599cd.com/THMember
LEARN MORE:
QueryDefs: 599cd.com/QueryDefs
PREREQUISITES:
Intro to VBA: 599cd.com/IntroVBA
SQL with Access: 599cd.com/SQLwithAccess
Status Box: 599cd.com/Status
LINKS:
Custom List Box: 599cd.com/CustomListBox
Parameter Query: 599cd.com/Parameter
Convert Query SQL to VBA: 599cd.com/1474
Record Source: 599cd.com/RecordSource
RECOMMENDED COURSES:
QueryDefs in Access Developer 37: 599cd.com/ACD37
Dynamic SQL Filtering in Access Developer 26: 599cd.com/ACD26L
Query Building in Access Developer 19: 599cd.com/ACD19
SQL Basics in Access Expert 3: 599cd.com/AC10X3
FREE TEMPLATE DOWNLOADS:
TechHelp Free Templates: 599cd.com/THFree
Blank Template: 599cd.com/Blank
Contact Management: 599cd.com/Contacts
Order Entry & Invoicing: 599cd.com/Invoicing
More Access Templates: 599cd.com/AccessTemplates
DIAMOND SPONSORS:
More info on our Sponsors: 599cd.com/DiamondSponsors
ADDITIONAL RESOURCES:
FREE Access Beginner Level 1: 599cd.com/Free1
How to Use Access in 30 Minutes: 599cd.com/30Minutes
$1 Access Level 2: 599cd.com/1Dollar
Donate to my Tip Jar: 599cd.com/TipJar
Merch Store! Get your swag here: 599cd.com/Merch
Get on my Mailing List: 599cd.com/YTML
Contact Me: 599cd.com/Contact
TechHelp: 599cd.com/TechHelp
Consulting Help: 599cd.com/DevNet
Twitter: twitter.com/LearningAccess
en.wikipedia.org/wiki/Microsoft_Access
products.office.com/en-us/access
microsoft.com/en-us/microsoft-365/blog/access
KEYWORDS:
TechHelp, Access 2016, Access 2019, Access 2021, Access 2024, Access 365, Microsoft Access, MS Access, MS Access Tutorial, #msaccess, #microsoftaccess, #help, #howto, #tutorial, #learn, #lesson, #training, #database, DAO QueryDef, CreateQueryDef VBA, Access QueryDef, create saved query with VBA, dynamic SQL query, CurrentDb.CreateQueryDef, dynamic SELECT fields, VBA query builder, temporary QueryDef, parameter queries, replace saved query, SQL field picker
QUESTIONS:
Please feel free to post your questions or comments below. Thanks.
Live long, and prosper.










