Need help on Join creation query

Vincen85

Registered User.
Local time
Today, 06:52
Joined
Mar 5, 2008
Messages
10
Hi! Im wondering why my code below Does not work!.... any suggestion???


strStatement = "SELECT SessionData.RunNumber, SessionData.SessionID, SessionData.SequenceNo, SessionData.SubjectID, SessionData.Latency, SessionData.BeamBrk1, SessionData.BeamBrk2, SessionData.BeamBrk3, SessionHeader.SessionDate, SessionHeader.ChamberNo" & _
"SessionHeader.GroupID, SessionHeader.SubjectVariables, SessionHeader.TestDefName FROM SessionData" & _
"INNER JOIN SessionHeader ON SessionData.RunNumber = SessionHeader.RunNumber;"


getQueryname = InputBox("Enter a name for New Query?", "Enter a Label or Name for Query", "Enter Query name/Label Here", 500, 700)

Set qryEmployees = curDatabase.CreateQueryDef("getQueryname", strStatement)
 
strStatement = "SELECT SessionData.RunNumber, SessionData.SessionID, SessionData.SequenceNo, SessionData.SubjectID, SessionData.Latency, SessionData.BeamBrk1, SessionData.BeamBrk2, SessionData.BeamBrk3, SessionHeader.SessionDate, SessionHeader.ChamberNo" & _
"SessionHeader.GroupID, SessionHeader.SubjectVariables, SessionHeader.TestDefName FROM SessionData" & _
"INNER JOIN SessionHeader ON SessionData.RunNumber = SessionHeader.RunNumber;"

if byou look at the red bits you will see that there is no space bewteen one word and the next - so the sql sysntax becomes invalid

access will tell you what is wrong

but do a msgbox(strstatement) before you use it, to see what it looks like, and check sysntax. spelling etc
 
Access only tells me

"Run-Time error '3131'"
"Syntax error in FROM clause"

the statement inside the "" are given to me from SQLview option from query that I have already made using simple query Wizard from Microsoft access...I doubt there is anything wrong there.... im just confuse why I got a FROM clause error...

Here is the exact format of SQL view from my existing query:
SELECT SessionData.RunNumber, SessionData.SessionID, SessionData.SequenceNo, SessionData.SubjectID, SessionData.Latency, SessionData.BeamBrk1, SessionData.BeamBrk2, SessionData.BeamBrk3, SessionHeader.SessionDate, SessionHeader.ChamberNo, SessionHeader.GroupID, SessionHeader.SubjectVariables, SessionHeader.TestDefName
FROM SessionData INNER JOIN SessionHeader ON (SessionData.RunNumber=SessionHeader.RunNumber) AND (SessionData.SubjectID=SessionHeader.SubjectID);
 
I have added a , to fix the

SessionHeader.ChamberNo," & _
"SessionHeader.GroupID (spacing problem)

however, I do not know what to do with

SessionData" & _
"INNER JOIN (spacing problem)

Please show me how to space them....or better yet how to fix the problem I am having in detail syntax... Thank you!
 
Nevermind I got it to work now....

Thanks for pointing em out! :D
 

Users who are viewing this thread

Back
Top Bottom