Solved

Code too wide for screen

Posted on 2014-03-02
7
312 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 39899082
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 29

Expert Comment

by:chilternPC
ID: 39899088
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
ID: 39899116
No the problem is entering the long list in the code window

Derek
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 33

Expert Comment

by:Norie
ID: 39899121
Derek

What code window are you referring to?

Are you trying to execute the INSERT using VBA?
0
 

Author Comment

by:DatabaseDek
ID: 39899131
Yes the VBA code window
0
 
LVL 33

Expert Comment

by:Norie
ID: 39899159
Then Scott's suggestion should work.
0
 

Author Closing Comment

by:DatabaseDek
ID: 39899328
Thank you All!!

Derek
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

735 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