Solved

Code too wide for screen

Posted on 2014-03-02
7
306 Views
Last Modified: 2014-03-02
I am listing a large number of fields in an sql statement that is too long for the width of the screen.

I have tried the underscore and  & _ but to no avail

How do you break into the middle of an INSERT INTO statement to create a line break without loosing the correct  syntax

Help
0
Comment
Question by:DatabaseDek
7 Comments
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
Comment Utility
I do it like this:

Dim sql As String

sql = "INSERT INTO MyTable(Col1, Col2, Col3) " _
  & " VALUES(" & Me.tx1 & "," _
  & Me.tx2 & "," _
  & Me.tx3 & ")"

Or you can do this:

sql = "INSERT INTO MyTable(Col1, Col2, Col3) "
sql = sql  & " VALUES(" & Me.tx1 & ","
sql = sql  & Me.tx2 & ","
sql = sql  & Me.tx3 & ")"
0
 
LVL 28

Expert Comment

by:chilternPC
Comment Utility
do you mean the statement is in a file?
just let the statement be without line breaks - although it wraps onto the next line there isn't a line break and so should execute ok.
0
 

Author Comment

by:DatabaseDek
Comment Utility
No the problem is entering the long list in the code window

Derek
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 33

Expert Comment

by:Norie
Comment Utility
Derek

What code window are you referring to?

Are you trying to execute the INSERT using VBA?
0
 

Author Comment

by:DatabaseDek
Comment Utility
Yes the VBA code window
0
 
LVL 33

Expert Comment

by:Norie
Comment Utility
Then Scott's suggestion should work.
0
 

Author Closing Comment

by:DatabaseDek
Comment Utility
Thank you All!!

Derek
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now