473,385 Members | 1,907 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Breaking sql into multiple lines

4
Hey guys. I'm doing my neighbor a favor and helping with her home business.

I'm new to sql and im trying to use a sql statement, but it is to long for one line. I dont know how to break it up into multiple lines without getting a compile error.

PS. The problem is the select line, it on it's own is too long. Some help would be great!

Expand|Select|Wrap|Line Numbers
  1. SELECT [Current Orders].Cust_Order_No, [Current Orders].New, [Current Orders].Buyer, [Current Orders].Brand, [Current Orders].Wine, [Current Orders].Vintage, [Current Orders].Qty, [Current Orders].Pack_Size, [Current Orders].Price, [Current Orders].Discount, [price]*[QTY] AS [Gross Price], [Gross Price]*[discount] AS [Nett Price1], [GROSS PRICE]-[NETT PRICE1] AS [NETT PRICE2], TblBuyer.Terms, TblBuyer.[Inco Term], TblBuyer.Freight_M, TblBuyer.Currency1, TblBuyer.Currency2, TblBuyer.[Account No], TblBuyer.Country, TblBuyer.Acc_Cust_Address1, TblBuyer.AC_Tel1, TblBuyer.AC_Tel2, TblBuyer.AC_Tel3, TblBuyer.AC_Fax1, TblBuyer.AC_Email1, TblBuyer.AC_Email2, TblBuyer.AC_Email3, TblBuyer.Del_Address1, TblBuyer.Del_Address2, TblBuyer.Del_Address3, TblBuyer.Del_Address4, TblBuyer.Cust_Notes, TblCurrency.[Banking Details], TblCurrency.Notes, [Current Orders].Est_DOS, [Current Orders].Inv_No, "APW0" & [inv_No] AS [Document No], TblBuyer.Terms_temp, TblBuyer.Inv_Notes, TblBuyer.Equipment, TblBuyer.[Load Instruction], TblBuyer.Courier_Details, TblBuyer.Contact_Cust, TblBuyer.Tel_Cust, TblBuyer.Contact_Courier, TblBuyer.Tel_Courier, TblBuyer.Contact_Consignee, TblBuyer.Tel_Consignee, TblBuyer.[Agent Involved], TblBuyer.POD, TblBuyer.[Final Destination], TblBuyer.Insulation, TblBuyer.[Documentation Requirements], [Current Orders].[Container No], [Current Orders].[Seal No], [Current Orders].Invoice_Date, TblBuyer.VATNo
  2. FROM [Current Orders] INNER JOIN (TblCurrency INNER JOIN TblBuyer ON TblCurrency.Currency = TblBuyer.Currency1) ON [Current Orders].Buyer = TblBuyer.Buyer
  3. WHERE ((([Current Orders].Inv_No)=[Please enter the invoice no]));
May 13 '10 #1

✓ answered by NeoPa

I'm not sure whether you are talking about SQL here or VBA. SQL needs no special handling of broken lines as it recognises only general white-space. VBA on the other hand requires the underscore (_) character to indicate continuation between lines.

As an illustration I'll post your SQL reformatted so that it is more readable. There is no change to the effect of the SQL :
Expand|Select|Wrap|Line Numbers
  1. SELECT [Current Orders].Cust_Order_No
  2.      , [Current Orders].New
  3.      , [Current Orders].Buyer
  4.      , [Current Orders].Brand
  5.      , [Current Orders].Wine
  6.      , [Current Orders].Vintage
  7.      , [Current Orders].Qty
  8.      , [Current Orders].Pack_Size
  9.      , [Current Orders].Price
  10.      , [Current Orders].Discount
  11.      , [price]*[QTY] AS [Gross Price]
  12.      , [Gross Price]*[discount] AS [Nett Price1]
  13.      , [GROSS PRICE]-[NETT PRICE1] AS [NETT PRICE2]
  14.      , TblBuyer.Terms
  15.      , TblBuyer.[Inco Term]
  16.      , TblBuyer.Freight_M
  17.      , TblBuyer.Currency1
  18.      , TblBuyer.Currency2
  19.      , TblBuyer.[Account No]
  20.      , TblBuyer.Country
  21.      , TblBuyer.Acc_Cust_Address1
  22.      , TblBuyer.AC_Tel1
  23.      , TblBuyer.AC_Tel2
  24.      , TblBuyer.AC_Tel3
  25.      , TblBuyer.AC_Fax1
  26.      , TblBuyer.AC_Email1
  27.      , TblBuyer.AC_Email2
  28.      , TblBuyer.AC_Email3
  29.      , TblBuyer.Del_Address1
  30.      , TblBuyer.Del_Address2
  31.      , TblBuyer.Del_Address3
  32.      , TblBuyer.Del_Address4
  33.      , TblBuyer.Cust_Notes
  34.      , TblCurrency.[Banking Details]
  35.      , TblCurrency.Notes
  36.      , [Current Orders].Est_DOS
  37.      , [Current Orders].Inv_No
  38.      , "APW0" & [inv_No] AS [Document No]
  39.      , TblBuyer.Terms_temp
  40.      , TblBuyer.Inv_Notes
  41.      , TblBuyer.Equipment
  42.      , TblBuyer.[Load Instruction]
  43.      , TblBuyer.Courier_Details
  44.      , TblBuyer.Contact_Cust
  45.      , TblBuyer.Tel_Cust
  46.      , TblBuyer.Contact_Courier
  47.      , TblBuyer.Tel_Courier
  48.      , TblBuyer.Contact_Consignee
  49.      , TblBuyer.Tel_Consignee
  50.      , TblBuyer.[Agent Involved]
  51.      , TblBuyer.POD
  52.      , TblBuyer.[Final Destination]
  53.      , TblBuyer.Insulation
  54.      , TblBuyer.[Documentation Requirements]
  55.      , [Current Orders].[Container No]
  56.      , [Current Orders].[Seal No]
  57.      , [Current Orders].Invoice_Date
  58.      , TblBuyer.VATNo
  59. FROM   [Current Orders] INNER JOIN
  60.        (TblCurrency INNER JOIN TblBuyer
  61.   ON   TblCurrency.Currency = TblBuyer.Currency1)
  62.   ON   [Current Orders].Buyer = TblBuyer.Buyer
  63. WHERE  ((([Current Orders].Inv_No)=[Please enter the invoice no]));
Welcome to Bytes!

2 4431
htdIO
4
Aaah, im getting to tired. Don't worry. Solved. Had '&_' instead of '& _'
May 13 '10 #2
NeoPa
32,556 Expert Mod 16PB
I'm not sure whether you are talking about SQL here or VBA. SQL needs no special handling of broken lines as it recognises only general white-space. VBA on the other hand requires the underscore (_) character to indicate continuation between lines.

As an illustration I'll post your SQL reformatted so that it is more readable. There is no change to the effect of the SQL :
Expand|Select|Wrap|Line Numbers
  1. SELECT [Current Orders].Cust_Order_No
  2.      , [Current Orders].New
  3.      , [Current Orders].Buyer
  4.      , [Current Orders].Brand
  5.      , [Current Orders].Wine
  6.      , [Current Orders].Vintage
  7.      , [Current Orders].Qty
  8.      , [Current Orders].Pack_Size
  9.      , [Current Orders].Price
  10.      , [Current Orders].Discount
  11.      , [price]*[QTY] AS [Gross Price]
  12.      , [Gross Price]*[discount] AS [Nett Price1]
  13.      , [GROSS PRICE]-[NETT PRICE1] AS [NETT PRICE2]
  14.      , TblBuyer.Terms
  15.      , TblBuyer.[Inco Term]
  16.      , TblBuyer.Freight_M
  17.      , TblBuyer.Currency1
  18.      , TblBuyer.Currency2
  19.      , TblBuyer.[Account No]
  20.      , TblBuyer.Country
  21.      , TblBuyer.Acc_Cust_Address1
  22.      , TblBuyer.AC_Tel1
  23.      , TblBuyer.AC_Tel2
  24.      , TblBuyer.AC_Tel3
  25.      , TblBuyer.AC_Fax1
  26.      , TblBuyer.AC_Email1
  27.      , TblBuyer.AC_Email2
  28.      , TblBuyer.AC_Email3
  29.      , TblBuyer.Del_Address1
  30.      , TblBuyer.Del_Address2
  31.      , TblBuyer.Del_Address3
  32.      , TblBuyer.Del_Address4
  33.      , TblBuyer.Cust_Notes
  34.      , TblCurrency.[Banking Details]
  35.      , TblCurrency.Notes
  36.      , [Current Orders].Est_DOS
  37.      , [Current Orders].Inv_No
  38.      , "APW0" & [inv_No] AS [Document No]
  39.      , TblBuyer.Terms_temp
  40.      , TblBuyer.Inv_Notes
  41.      , TblBuyer.Equipment
  42.      , TblBuyer.[Load Instruction]
  43.      , TblBuyer.Courier_Details
  44.      , TblBuyer.Contact_Cust
  45.      , TblBuyer.Tel_Cust
  46.      , TblBuyer.Contact_Courier
  47.      , TblBuyer.Tel_Courier
  48.      , TblBuyer.Contact_Consignee
  49.      , TblBuyer.Tel_Consignee
  50.      , TblBuyer.[Agent Involved]
  51.      , TblBuyer.POD
  52.      , TblBuyer.[Final Destination]
  53.      , TblBuyer.Insulation
  54.      , TblBuyer.[Documentation Requirements]
  55.      , [Current Orders].[Container No]
  56.      , [Current Orders].[Seal No]
  57.      , [Current Orders].Invoice_Date
  58.      , TblBuyer.VATNo
  59. FROM   [Current Orders] INNER JOIN
  60.        (TblCurrency INNER JOIN TblBuyer
  61.   ON   TblCurrency.Currency = TblBuyer.Currency1)
  62.   ON   [Current Orders].Buyer = TblBuyer.Buyer
  63. WHERE  ((([Current Orders].Inv_No)=[Please enter the invoice no]));
Welcome to Bytes!
May 14 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: JStrauss | last post by:
Hello, Can anybody give me some tips on the best and/or easiest way to display multiple lines in a field. The data is collected from a "textarea" field when the form is submitted, and I want to...
2
by: Wow | last post by:
Do I have to replace all new lines with \n and document.write one line? Is there something like perl's print lines print << 'body'; body in javascripts?
0
by: michael | last post by:
Hi all, i want to know how to display multiple lines in one crystal report chart in asp.net i wrote some codes but it always display 2 lines in separate chart(please refer to the codes...
4
by: tshad | last post by:
I have a textbox that I am storing as text (or as a varChar). The field has multiple lines in it (not wrapped). When I read it back into a multiline textbox, it works fine. But when I read it...
2
by: George | last post by:
Dear colleagues, I refer to your help with specific graphic problem. It is necessary to create a viewfinder in graphic application. It seems that the algorithm is simple: just draw lines in...
1
by: Loading name... | last post by:
hey asp.net 2.0 In my db (sql server 2005) I have a record which consist of multiple lines: "HEY THIS IS A TEST OF MULTIPLE LINES"
7
by: =?Utf-8?B?TG9zdEluTUQ=?= | last post by:
Hi All :) I'm converting VB6 using True DBGrid Pro 8.0 to VB2005 using DataGridView. True DBGrid has a MultipleLines property that controls whether individual records span multiple lines. Is...
0
by: chitta | last post by:
Hi I have a problem when i am looping on multiple lines. the question as follows If OrderProductLineItem (DocType='OrderCreate'/'OrderChange') < OrderProductLineItem...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.