The roots of education are bitter,
but the fruit is sweet.
Home   News   Courses   Seminars   Templates   Help   TechHelp   Forums   Order   Contact   Logon  
Home > TechHelp > Directory > Access > SQL to VBA < Alpha Grouping | Fast Form Update >
Convert Query SQL to VBA
By Richard Rost   Richard Rost on Facebook Richard Rost on Twitter Richard Rost on LinkedIn Email Richard Rost   19 days ago

Convert Query SQL to VBA Code. Add Line Breaks, Quotes, More.

 S  M  L  XL  FS  Join Now

Do you copy a lot of SQL from the query designer SQL view over to the VBA editor to use in your code, and you spend a lot of time "fixing" the string, adding line continuation characters, adding quotes, etc. Well, in this video we'll make a little utility you can use to perform that task with one click. You can use this in a RunSQL statement or a Me.RecordSource change.

John from Hancock, New Hampshire (a Silver Member) asks: Is there a way to format the SQL text of a query with the proper line breaks and quotes so I can copy it to my VBA editor for a RunSQL command without doing all that manual editing?


I'll walk you through some additional modifications to the utility, including splitting long lines up, loading a listbox with all of the queries in the database, and one-click to copy the SQL to the editor textbox and convert it.

Silver Members and up get access to an Extended Cut of this video. Gold Members can download the database template from class plus get access to the Code Vault. If you signed up on YouTube you have to contact me so I can set up your account here on my web site. If you're not a member, Join Today!


Replace Function:
Double Double Quotes:
Intro to VBA:

Learn More

FREE Access Beginner Level 1
Access Level 2 for $1.00

Free Templates

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


Mailing List - Get Emails When New Videos Released!
Consulting - Need Help with Your Database?


Please feel free to post your questions or comments below or submit them via the TechHelp page.


SetWarnings Reversed Link 
James Gray 
6 days ago
I noticed that the VBA code constructed via the utility has the Set Warnings True statement first instead of Set Warning False.   I think the problem is with the construction of Status function.  I fixed it by changing the order of construction for StatusBox to: StatusBox = StatusBox & vbNewLine & S instead of: StatusBox = s & vbnewline & Statusbox.  Do I have this correct?
Richard Rost
6 days ago
You may indeed be correct. I didn't notice it. I'll check the video when I have some free time, but what you're saying sounds about right. Thanks. :)
Add a Reply

Post a New Comment or Question
Only students may post right now. Click here for more information on how you can set up an account. If you are a student, please LOG ON first.

You may want to read these articles from the 599CD News:

1/7/2021Filter Characters
12/31/2020Convert Query SQL to VBA
12/21/2020Introduction to Access VBA
12/12/2020Customer Contact Template
11/13/2020Calculate Exact Age
11/13/2020myNetWorkDays Function
11/13/2020Easter Sunday Calculation
10/31/2020Current UTC Time
10/16/2020InStr2 Search a List of Chars
10/10/2020Create Your Own Function

Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Account Login
Online Theater
Lost Password
Free Upgrades
Insider Circle
Student Databases
Change Email
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Waiting List
Production Schedule
Code Vault
Collapse Menus
Live Chat
Customer Support
WalkThru Tutorials
Consulting Services
Affiliate Program
Richard Rost
Free Lessons
Mailing List
Video Tutorials
MYOLP Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Terms of Sale
Live Chat
General Info
Support Policy
Contact Form
Email Richard
Mailing Address
Phone Number
Fax Number
Course Survey
Facebook    Twitter

YouTube Channel    LinkedIn

Blog RSS Feed   
Keywords: TechHelp Access line breaks, vbnewline, vbtab, sql to vba, convert sql, convert to vba, line continuation character, runsql, recordsource, setfocus, copy to clipboard  PermaLink