Convert Query SQL to VBA Code in Microsoft Access. Add Line Breaks, Quotes, vbNewLine, and More.

  Рет қаралды 25,942

Computer Learning Zone

Computer Learning Zone

Күн бұрын

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.
LEVEL: Developer (SQL and VBA coding)
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?
BONUS FOR CHANNEL MEMBERS:
Silver Members and up get access to a 30 MINUTE EXTENDED CUT of this video which walks 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.
MEMBERS ONLY VIDEO:
• Convert Query SQL to V...
BECOME A MEMBER:
/ @599cd
LINKS:
Replace Function: 599cd.com/Replace
Me.RecordSource: 599cd.com/Reco...
Double Double Quotes: 599cd.com/Doub...
SetFocus: 599cd.com/SetF...
Intro to VBA: 599cd.com/Intr...
ADDITIONAL RESOURCES:
Get on my Mailing List: 599cd.com/YTML
FREE Access Beginner Level 1: 599cd.com/Free1
FREE Blank Customer Template: 599cd.com/FRL2
$1 Access Level 2: 599cd.com/1Dollar
TechHelp: 599cd.com/Tech...
Twitter: / learningaccess
en.wikipedia.o...
products.offic...
microsoft.com/...
Email Me: amicron@gmail.com
WHAT DOES LEVEL MEAN:
My Access classes are divided into multiple levels. BEGINNER requires little working knowledge of Access. EXPERT assumes you know relationships and how to use functions. ADVANCED users know macros and events. DEVELOPER uses SQL and/or VBA programming.
KEYWORDS:
microsoft access, ms access, #msaccess, #microsoftaccess, line breaks, vbnewline, vbtab, sql to vba, convert sql, convert to vba, line continuation character, runsql, recordsource, setfocus, copy to clipboard
QUESTIONS:
Please feel free to post your questions or comments below. Thanks.

Пікірлер: 26
@scottaxton2513
@scottaxton2513 3 жыл бұрын
5-Stars! This video alone just saved me HOURS of work converting a db using macros from the 1990's to this century. Kudos and Thanks! Scott
@599CD
@599CD 3 жыл бұрын
My pleasure, Scott.
@johnmcfarlane8805
@johnmcfarlane8805 3 жыл бұрын
Remarkable stuff from our favourite MVP!
@599CD
@599CD 3 жыл бұрын
Technically "former" MVP. The Microsoft MVP award is an annual prize. I was awarded it in 2014 and 2015, but then due to health reasons I took some time off and wasn't actively involved in the tech community for a few years. Hopefully they'll reconsider me in 2021. I love helping folks, posting my videos, and answering emails, which is one of the things they consider.
@timfulton6920
@timfulton6920 3 жыл бұрын
Looks good and I love the concept. I hadn't done any lessons on SQL in VBA and formatting but this was easy to follow. I did find I ran info an error when trying to use the SQL statement with "CurrentDb.OpenRecordset" "Error Number: 3131- Syntax error in FROM clause." I found it was because my SQL statement didn't have a space at the end of the FROM Line. "FROM QRY_SO_ALL" & _ (Incorrect) "FROM QRY_SO_ALL " & _ (correct) I didn't see in the video a spot that addressed that in the video. I hope this helps anyone with a similar issue.
@599CD
@599CD 3 жыл бұрын
Yeah that could be. It's a very "version 1.0" piece of software.
@colinhursell9176
@colinhursell9176 3 жыл бұрын
Thank you! Really useful information!
@599CD
@599CD 3 жыл бұрын
Glad you like it.
@zoomingby
@zoomingby 4 ай бұрын
The fact that Access creates SQL in such a way that can't be readily used in VBA is inexcusable and absurd.
@mohammedalsarraj9963
@mohammedalsarraj9963 Жыл бұрын
Great review
@599CD
@599CD Жыл бұрын
Thanks
@ssdusd
@ssdusd 2 жыл бұрын
Greate!. But how will you go back to the base query after changing RecordSource?
@599CD
@599CD Жыл бұрын
I get a ton of questions every day, and I don't have time to answer them all here on KZbin. Feel free to submit your question on my website at: 599cd.com/AskYT
@teemoto3923
@teemoto3923 Жыл бұрын
One the first functions i add to my dbs is one that adds vbnewlines and give it a short name. for example cr(2) returns two lines. Saves on typing
@mafgeology
@mafgeology 3 жыл бұрын
Great 👍
@599CD
@599CD 3 жыл бұрын
Thank you 👍
@nairobi203
@nairobi203 Жыл бұрын
This is like Parmesan Cheese on a nice plate of Spaghetti with Tomato sauce.... Perfect... -:)
@599CD
@599CD Жыл бұрын
Don't fuggetta bout da meat BALLS!
@ashishtrivedi8253
@ashishtrivedi8253 3 жыл бұрын
With docmd.runqul statement or me.recordset statement error saying required sql statement... I search on net it says only update or similar statement can run by this .. select statement can't! I can see your doing it.. please tell me how? Thx in advance
@599CD
@599CD 3 жыл бұрын
Without seeing your statements, it's impossible to tell what the problem is. I did have one user who discovered that if you use SPACES in your field or table names, my converter doesn't work. But my Rule #1 that I teach in Access Beginner Level 1 is DON'T use spaces in field or table names. :)
@ashishtrivedi8253
@ashishtrivedi8253 2 жыл бұрын
@@599CD sorry for late response on this but that point of time i was desperate ;) but finally i figured it out, Docmd cant execute select statement. If anyone wants to try that can use ADO and it will work.
@dbdata9836
@dbdata9836 3 жыл бұрын
thanks
@599CD
@599CD 3 жыл бұрын
Welcome
Understanding Recordsets in Microsoft Access VBA - a Beginner's Guide
20:48
Computer Learning Zone
Рет қаралды 9 М.
Крутой фокус + секрет! #shorts
00:10
Роман Magic
Рет қаралды 26 МЛН
Will A Guitar Boat Hold My Weight?
00:20
MrBeast
Рет қаралды 264 МЛН
Ozoda - Lada ( Official Music Video 2024 )
06:07
Ozoda
Рет қаралды 18 МЛН
The Joker wanted to stand at the front, but unexpectedly was beaten up by Officer Rabbit
00:12
An Introduction to VBA Code in Microsoft Access
9:51
MyExcelOnline.com
Рет қаралды 18 М.
How to Create and Modify QueryDefs Programmatically in your MS Access Database
12:03
Sean MacKenzie Data Engineering
Рет қаралды 4,7 М.
VBA SQL Strings - Tutorial for Beginner
36:14
codekabinett.com/en
Рет қаралды 57 М.
Microsoft Access Tips | How to EDIT Records using VBA Recordsets
17:46
How to use Microsoft Access - Beginner Tutorial
31:07
Kevin Stratvert
Рет қаралды 3,2 МЛН
How to Handle Line Breaks in Microsoft Access
20:04
Sean MacKenzie Data Engineering
Рет қаралды 2,6 М.
A Better Solution Than the On Filter Event in Microsoft Access Forms
29:42
Computer Learning Zone
Рет қаралды 6 М.
Крутой фокус + секрет! #shorts
00:10
Роман Magic
Рет қаралды 26 МЛН