Unable to build query on the Fly in Access 2007 ADP

I am trying to build a query on the fly with VBA. For some odd reason it seems to be cutting off my variables short.

//Current Statement
Dim sQuery As String
sQuery = "SELECT      dbo.VALVEINFO.NOMINALVALVESIZE, dbo.VALVEINFO.INTERNALVALVESIZE, dbo.VALVEINFO.PRESSURECLASS, dbo.VALVEINFO.VALVETYPE, " _
& "dbo.VALVEINFO.ACTUATION, dbo.VALVEINFO.NOTES, dbo.VALVEINFO.ENDCONNECTIONS, dbo.DRAWINGS.DRAWINGNUMBER, " _
& "dbo.VALVEINFO.DRAWINGID , dbo.VALVEINFO.VALVEID " _
& "FROM          dbo.DRAWINGS INNER JOIN " _
& "dbo.VALVEINFO ON dbo.DRAWINGS.DRAWINGID = dbo.VALVEINFO.DRAWINGID "

What shows up(in the debug screen):
"SELECT      dbo.VALVEINFO.NOMINALVALVESIZE, dbo.VALVEINFO.INTERNALVALVESIZE, dbo.VALVEINFO.PRESSURECLASS, dbo.VALVEINFO.VALVETYPE, dbo.VALVEINFO.ACTUATION, dbo.VALVEINFO.NOTES, dbo.VALVEINFO.ENDCONNECTIONS, dbo.DRAWINGS.DRAWINGNUMBER, dbo.VALVEINFO.DRAW"

Its almost like its cutting it off. I do have the Where section building fine, but when i try to concatenate them together, it shows this:
"SELECT      dbo.VALVEINFO.NOMINALVALVESIZE, dbo.VALVEINFO.INTERNALVALVESIZE, dbo.VALVEINFO.PRESSURECLASS, dbo.VALVEINFO.VALVETYPE, dbo.VALVEINFO.ACTUATION, dbo.VALVEINFO.NOTES, dbo.VALVEINFO.ENDCONNECTIONS, dbo.DRAWINGS.DRAWINGNUMBER, dbo.VALVEINFO.DRAW"

What do i seem to be missing?
tekkieguruAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Richard DanekeTrainerCommented:
Concatentate your SQL.
use somethhing like:

Dim sQuery As String

sQuery = "SELECT      dbo.VALVEINFO.NOMINALVALVESIZE, dbo.VALVEINFO.INTERNALVALVESIZE, dbo.VALVEINFO.PRESSURECLASS, dbo.VALVEINFO.VALVETYPE, "
SQuery = sQuery & "dbo.VALVEINFO.ACTUATION, dbo.VALVEINFO.NOTES, dbo.VALVEINFO.ENDCONNECTIONS, dbo.DRAWINGS.DRAWINGNUMBER, "
 SQuery = sQuery & "dbo.VALVEINFO.DRAWINGID , dbo.VALVEINFO.VALVEID FROM          dbo.DRAWINGS INNER JOIN " 
SQuery = sQuery & "dbo.VALVEINFO ON dbo.DRAWINGS.DRAWINGID = dbo.VALVEINFO.DRAWINGID "

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RDWaibelCommented:
Try this and post back the results of the DEBUG.PRINT

Dim sQuery As String
sQuery = "SELECT dbo.VALVEINFO.NOMINALVALVESIZE, dbo.VALVEINFO.INTERNALVALVESIZE, dbo.VALVEINFO.PRESSURECLASS, dbo.VALVEINFO.VALVETYPE, " _
& "dbo.VALVEINFO.ACTUATION, dbo.VALVEINFO.NOTES, dbo.VALVEINFO.ENDCONNECTIONS, dbo.DRAWINGS.DRAWINGNUMBER, " _
& "dbo.VALVEINFO.DRAWINGID , dbo.VALVEINFO.VALVEID " _
& "FROM dbo.DRAWINGS INNER JOIN " _
& "dbo.VALVEINFO ON dbo.DRAWINGS.DRAWINGID = dbo.VALVEINFO.DRAWINGID;"
Debug.Print sQuery
0
tekkieguruAuthor Commented:
Looks like that took care of it. Not sure why the other way wasnt working, but i'm used to working in Visual Studio using .net.

Thanks alot for the help!
0
Richard DanekeTrainerCommented:
Thank you.  It seems almost arbitrary, but there is some limit to the length of strings as you continue your lines.  It gets even more complicated with different editors - Visual Basic, VBA, SQL, etc.
Concatenating just simplifies putting the string together successfully without having to worry about the limit.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.