R
ryguy7272
I am trying to figure out how to break some SQL into VBA. I feel like I’m
almost there, but I seem to be missing something. Below is my VBA:
strSQL = "SELECT SharePrices.StockSymbol, tblStocksGroup.Company,
tblStocksGroup.Group, tblStocksGroup.Class, qry0.DateTime AS [Date],
([30Days]-[ZeroDays])/[ZeroDays] AS [30Day%Return],
([90Days]-[ZeroDays])/[ZeroDays] AS [90Day%Return],
([180Days]-[ZeroDays])/[ZeroDays] AS [180Day%Return],
([365Days]-[ZeroDays])/[ZeroDays] AS [365Day%Return], AND " & _
"tblStocksGroup.HDVest50k, tblStocksGroup.HDVest100k, tblStocksGroup.ETF,
tblStocksGroup.NetJets, tblStocksGroup.JetBlue,
tblStocksGroup.JetBlueTradeLink, tblStocksGroup.AirWisconsin,
tblStocksGroup.Alaska, tblStocksGroup.American, tblStocksGroup.Continental,
tblStocksGroup.Delta, tblStocksGroup.Frontier, tblStocksGroup.Southwest,
tblStocksGroup.UnitedFAS, tblStocksGroup.UnitedPilots,
tblStocksGroup.WorldAirway, tblStocksGroup.LeveragedLong,
tblStocksGroup.LeveragedShort, tblStocksGroup.Other1, tblStocksGroup.Other2,
qry0.StockPrice AS ZeroDays, qry30.StockPrice AS 30Days, qry90.StockPrice AS
90Days, qry180.StockPrice AS 180Days, qry365.StockPrice AS 365Days " & vbCrLf
& _
"FROM…etc.
As I know, this is for breaking within a command, like if the Select is too
long to fit on one line in the VBE:
AND " & _
As I know, this is for breaking from command to command, like Select to From:
& vbCrLf & _
I keep getting an error message that says: Run time Error
Syntax error (missing operator) in query expression ‘AND
tblStocksGroup.HDVest50k’
This is immediately after I add my break: AND " & _
I saw some documentation on where to add breaks a long time ago; can’t seem
to find it now. I know there are some places one can NOT add a break; this
must be one. Where do I add the break to make this work?
Thanks!
Ryan---
almost there, but I seem to be missing something. Below is my VBA:
strSQL = "SELECT SharePrices.StockSymbol, tblStocksGroup.Company,
tblStocksGroup.Group, tblStocksGroup.Class, qry0.DateTime AS [Date],
([30Days]-[ZeroDays])/[ZeroDays] AS [30Day%Return],
([90Days]-[ZeroDays])/[ZeroDays] AS [90Day%Return],
([180Days]-[ZeroDays])/[ZeroDays] AS [180Day%Return],
([365Days]-[ZeroDays])/[ZeroDays] AS [365Day%Return], AND " & _
"tblStocksGroup.HDVest50k, tblStocksGroup.HDVest100k, tblStocksGroup.ETF,
tblStocksGroup.NetJets, tblStocksGroup.JetBlue,
tblStocksGroup.JetBlueTradeLink, tblStocksGroup.AirWisconsin,
tblStocksGroup.Alaska, tblStocksGroup.American, tblStocksGroup.Continental,
tblStocksGroup.Delta, tblStocksGroup.Frontier, tblStocksGroup.Southwest,
tblStocksGroup.UnitedFAS, tblStocksGroup.UnitedPilots,
tblStocksGroup.WorldAirway, tblStocksGroup.LeveragedLong,
tblStocksGroup.LeveragedShort, tblStocksGroup.Other1, tblStocksGroup.Other2,
qry0.StockPrice AS ZeroDays, qry30.StockPrice AS 30Days, qry90.StockPrice AS
90Days, qry180.StockPrice AS 180Days, qry365.StockPrice AS 365Days " & vbCrLf
& _
"FROM…etc.
As I know, this is for breaking within a command, like if the Select is too
long to fit on one line in the VBE:
AND " & _
As I know, this is for breaking from command to command, like Select to From:
& vbCrLf & _
I keep getting an error message that says: Run time Error
Syntax error (missing operator) in query expression ‘AND
tblStocksGroup.HDVest50k’
This is immediately after I add my break: AND " & _
I saw some documentation on where to add breaks a long time ago; can’t seem
to find it now. I know there are some places one can NOT add a break; this
must be one. Where do I add the break to make this work?
Thanks!
Ryan---