Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
SQL in VBA Line Break
Ashlyn M Talley 
    
5 years ago
Hello Everyone, I have a subroutine that I'm running that performs/executes the below SQL statement. I there anyway I can place a line break before the "Submit" so that begins on a new line?

STR = "INSERT INTO tbl_ServiceNotes (Journey_Number, Tag, Services, Notes) " & _
            "VALUES (" & JNN & ", 'ToDo','ABA', '" & MySender & " Submit this authorization upon next contact')"
Scott Axton  @Reply  
        
4 years ago
Ashlyn - I responded earlier and then realized I posted a bad solution.  That one is deleted.  Sorry if you got multiple notifications.

So...  You can't mix VBA into an SQL statement. You have to deal with the VBA first then use the result in the SQL.

Dim NN as String  'New Notes

    NN = MySender &  vbNewLine & "Submit this authorization upon next contact"


'You can now use the NN in your SQL

   STR = "INSERT INTO tbl_ServiceNotes (Journey_Number, Tag, Services, Notes) " & _
            "VALUES (" & JNN & ", 'ToDo','ABA', '" & NN & ")"


Unless I mistyped this should work for you.
Scott Axton  @Reply  
        
4 years ago
Sorry just saw that I missed a single quote.
I believe you need   "')"   at the very end of the SQL statement
Ashlyn M Talley OP  @Reply  
    
4 years ago
Hi Scott, for some reason don't get any notifications as to replies or updates, seems I've also checked my spam filter. Thanks so much for both being so help and thorough. Not mixing SQL & VBA, after your mention now makes total sense. Thanks again!
Scott Axton  @Reply  
        
4 years ago
You are welcome.  Hope that did what you wanted.
Richard Rost  @Reply  
           
4 years ago
If you're working JUST with Access (and not SQL Server) try to get in the habit of using double-double quotes instead of single quotes. Trust me. You'll get a last name like D'Angelo and it will mess up your strings.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/9/2026 2:39:18 PM. PLT: 1s