Code too wide for screen

Derek Brown
Derek Brown used Ask the Experts™
on
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
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2012
Top Expert 2014
Commented:
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 & ")"
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.

Author

Commented:
No the problem is entering the long list in the code window

Derek
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

NorieAnalyst Assistant

Commented:
Derek

What code window are you referring to?

Are you trying to execute the INSERT using VBA?

Author

Commented:
Yes the VBA code window
NorieAnalyst Assistant

Commented:
Then Scott's suggestion should work.

Author

Commented:
Thank you All!!

Derek

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial