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
Solved

Code too wide for screen

Posted on 2014-03-02
7
311 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
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 28

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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
corrupt Databases 9 64
Export to Excel 7 33
trim dropdown value before executing query 8 26
Access Creating a report using a date range 11 10
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

809 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