0

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?

2
  • What error message are you getting? That always helps us. Commented Nov 27, 2015 at 13:30
  • MS Access doesn't allow use constants in join conditions. Commented Nov 27, 2015 at 13:39

2 Answers 2

2

I think you will need to CROSS JOIN the table Groups and then place T4.ID in the WHEREclause 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; 
Sign up to request clarification or add additional context in comments.

2 Comments

Thx for your answer, I really never had to use cross joins but it could make sense... I tried the first solution since I don't want to use the relation between Groups and AllQuestions, but I get this error when executing : syntax error in the where clause, and the word CROSS is highlighted...
This is the solution, only Access doesn't have the CROSS JOIN keyword. Instead of it, simply use a comma , in the FROM list.
0

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) 

2 Comments

I tried that and I get an error saying : The format of this GUID is incorrect: "T4.ID = {0 ".
You need, of course, to run the replace before running the SQL.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.