简体   繁体   中英

Access SQL JOIN Expression Not Supported

I know there are a bunch of questions on here dealing of unsupported join expressions, I just can't find one that refers to my situation.

My query looks like this :

SELECT T1.*, T2.Year, T3.Force, T4.Group AS myGroup
FROM ((AllQuestions AS T1 
INNER JOIN Years AS T2 ON T1.ID_Year = T2.ID) 
INNER JOIN Forces AS T3 ON T1.Questions_Force = T3.ID)
INNER JOIN Groups AS T4 ON  T4.ID = " & (Me.Texte423) & "
ORDER BY Categories, T1.Questions;

As you can see on line refering to T4, I'm trying to match the ID in table Groups to match a value from a textbox in a report (it might be important to mention).

The error i'm getting looks like : JOIN expression not supported. "looks" because i'm using a french version of Access, so it's a basic translation...

What am I doing wrong please?

I think you will need to CROSS JOIN the table Groups and then place T4.ID in the WHERE clause of your query but this doesn't resolve the relationship that may exist between T4.ID and the other ID columns that are being used to join the other tables:

SELECT T1.*, T2.Year, T3.Force, T4.Group AS myGroup
FROM ((AllQuestions AS T1 
INNER JOIN Years AS T2 ON T1.ID_Year = T2.ID) 
INNER JOIN Forces AS T3 ON T1.Questions_Force = T3.ID)
CROSS JOIN Groups AS T4 
WHERE T4.ID = " & (Me.Texte423) & "
ORDER BY Categories, T1.Questions;

If there is a relationship between Groups and AllQuestions on ID then you need to modify your query along these lines:

SELECT T1.*, T2.Year, T3.Force, T4.Group AS myGroup
FROM ((AllQuestions AS T1 
INNER JOIN Years AS T2 ON T1.ID_Year = T2.ID) 
INNER JOIN Forces AS T3 ON T1.Questions_Force = T3.ID)
INNER JOIN Groups AS T4 ON T1.{Group ID Relation} = T4.ID
WHERE T4.ID = " & (Me.Texte423) & "
ORDER BY Categories, T1.Questions; 

You can't do that. But you can modify the SQL of the query. Set it to:

SELECT T1.*, T2.Year, T3.Force, T4.Group AS myGroup
FROM ((AllQuestions AS T1 
INNER JOIN Years AS T2 ON T1.ID_Year = T2.ID) 
INNER JOIN Forces AS T3 ON T1.Questions_Force = T3.ID)
INNER JOIN Groups AS T4 ON  T4.ID = {0}
ORDER BY Categories, T1.Questions;

Then set/modify the SQL when you need it:

MyQdy.SQL = Replace(SQL, "{0}", Me!Texte423.Value) 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM