Hello
I am trying to write a SQL statement based on a SQL statement from the QBE
grid. The QBE query takes values from multiple tables.
SELECT IIf([table1].[field_1] Is Not Null, ("Val is true", "Val is false",))
As [field_A], IIf([table2].[field_1] Is Not Null, ("Val is true", "Val is
false",)) As [field_B], ([tablen].[field_n] Is Not Null, ("Val is true", "Val
is false",)) As [field_n]
FROM ((table1
INNER JOIN [table1].[table2]
LEFT JOIN [table1].[table3]
LEFT JOIN [table1].[table4]
INNER JOIN [table1].[table5]
LEFT JOIN [table1].[table6]
LEFT JOIN [table1].[table7]
I am trying to rewrite this into workable SQL that I can pass as string
using Access VBA. When I try to paste QBE SQL in Access VBA as a string I get "expected.. ." error message (Sounds like it needs a bracket to be closed). I thought about nested subqueries but I want to make sure that the joins are correct.
My nested attempt (giving syntax errors):
SELECT [field_1] AS '[field_A]' ('Val is true')" & _
"FROM [table1]" & _
"WHEN [field_1] Is Not Null" & _
"WHERE [field_2] IN" & _
"(SELECT [field_2] AS '[field_B] ('Val is true')" & _
"FROM [table2]" & _
"WHEN [field_1] Is Not Null" & _
"WHERE [field_3] IN" & _
"(SELECT [field_n] AS '[field_n] ('Val is true')" & _
"FROM [tablen]" & _
"WHEN [field_n] Is Not Null" & _
"WHERE [field_5] IN" & _
How can I do this please?
Thanks
I am trying to write a SQL statement based on a SQL statement from the QBE
grid. The QBE query takes values from multiple tables.
SELECT IIf([table1].[field_1] Is Not Null, ("Val is true", "Val is false",))
As [field_A], IIf([table2].[field_1] Is Not Null, ("Val is true", "Val is
false",)) As [field_B], ([tablen].[field_n] Is Not Null, ("Val is true", "Val
is false",)) As [field_n]
FROM ((table1
INNER JOIN [table1].[table2]
LEFT JOIN [table1].[table3]
LEFT JOIN [table1].[table4]
INNER JOIN [table1].[table5]
LEFT JOIN [table1].[table6]
LEFT JOIN [table1].[table7]
I am trying to rewrite this into workable SQL that I can pass as string
using Access VBA. When I try to paste QBE SQL in Access VBA as a string I get "expected.. ." error message (Sounds like it needs a bracket to be closed). I thought about nested subqueries but I want to make sure that the joins are correct.
My nested attempt (giving syntax errors):
SELECT [field_1] AS '[field_A]' ('Val is true')" & _
"FROM [table1]" & _
"WHEN [field_1] Is Not Null" & _
"WHERE [field_2] IN" & _
"(SELECT [field_2] AS '[field_B] ('Val is true')" & _
"FROM [table2]" & _
"WHEN [field_1] Is Not Null" & _
"WHERE [field_3] IN" & _
"(SELECT [field_n] AS '[field_n] ('Val is true')" & _
"FROM [tablen]" & _
"WHEN [field_n] Is Not Null" & _
"WHERE [field_5] IN" & _
How can I do this please?
Thanks
Comment