sql joint syntax error

ckannakc

New member
Local time
Today, 15:34
Joined
Jan 11, 2013
Messages
3
I am going slightly up the wall with this, so hopefully someone can help me.

I have the following sql in VBA, but am getting a syntax in join operation error - the query runs fine on the sql server. Anyone know what I am doing wrong?

Code:
Me.RecordSource = ("SELECT dbo_tbldCases.* FROM ((dbo_tbllClientGroups INNER JOIN" & _
                            "dbo_tbllClientGroupAssoc ON dbo_tbllClientGroups.ClientGroupID = dbo_tbllClientGroupAssoc.ClientGroupID) INNER JOIN" & _
                            "dbo_tbldPeople ON dbo_tbllClientGroupAssoc.ClientTypeID = dbo_tbldPeople.ClientT) INNER JOIN" & _
                            "dbo_tbldCases ON dbo_tbldPeople.CaseID = dbo_tbldCases.CaseID" & _
                            "WHERE tbllClientGroupAssoc.ClientGroupID = " & Me.cmbFilterClientType & ";")
 
I am going slightly up the wall with this, so hopefully someone can help me.

I have the following sql in VBA, but am getting a syntax in join operation error - the query runs fine on the sql server. Anyone know what I am doing wrong?

Code:
Me.RecordSource = ("SELECT dbo_tbldCases.* FROM ((dbo_tbllClientGroups INNER JOIN" & _
                            [COLOR=Red]"d[/COLOR]bo_tbllClientGroupAssoc ON dbo_tbllClientGroups.ClientGroupID = dbo_tbllClientGroupAssoc.ClientGroupID) INNER JOIN" & _
                            [COLOR=Red]"d[/COLOR]bo_tbldPeople ON dbo_tbllClientGroupAssoc.ClientTypeID = dbo_tbldPeople.ClientT) INNER JOIN" & _
                           [COLOR=Red] "d[/COLOR]bo_tbldCases ON dbo_tbldPeople.CaseID = dbo_tbldCases.CaseID" & _
                            [COLOR=Red]"W[/COLOR]HERE tbllClientGroupAssoc.ClientGroupID = " & Me.cmbFilterClientType & ";")

You need a space before the highlighted text, or after the JOIN statement.
 
MY HERO! thank you.

...is probably time for me to go home...
 
For future reference. When you are creating a complex string, put it in a variable so you can print the variable to the immediate window and see what you've got. If you still don't see the syntax error, copy the string from the immediate window and paste it into a query. The query editor will frequently give you better error messages than you get from running the query from VBA.
 

Users who are viewing this thread

Back
Top Bottom