• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 326
  • Last Modified:

Code too wide for screen

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
Derek Brown
Asked:
Derek Brown
1 Solution
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
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
 
Peter HartCommented:
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
 
Derek BrownMDAuthor Commented:
No the problem is entering the long list in the code window

Derek
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
NorieVBA ExpertCommented:
Derek

What code window are you referring to?

Are you trying to execute the INSERT using VBA?
0
 
Derek BrownMDAuthor Commented:
Yes the VBA code window
0
 
NorieVBA ExpertCommented:
Then Scott's suggestion should work.
0
 
Derek BrownMDAuthor Commented:
Thank you All!!

Derek
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now