Hi All,
I am trying to move many queries to be operated by command buttons on a form by using the DoCmd.runSQL command. Most of them work just fine but several have syntax problems.
When the command button is clicked an error message reads:
Syntax error (missing operator) in query expression "ImpLabelLines.NA7FROM ImpLabelLinesWhere (((ImpLabelLines(ImpLabelLines.NA7 <>"));'
The problems seem to be in complex WHERE clauses that are filled with (not isnull and <> ""). Is there a syntax difference for Access SQL and SQL in VBA code?
I tried using the SQL statement directly with the runSQL and putting the SQL all on one line and there is no difference.
I could not find a way to run named queries but this might solve the problem as well. The full statement is below:
Sql1a = "INSERT INTO WkDt ( IdSource, NAME1, NAME2, NAME3, NAME4, ADDR1, ADDR2, CSZ )" & _
"SELECT ImpLabelLines.IdSource, ImpLabelLines.NA1, ImpLabelLines.NA2, ImpLabelLines.NA3, ImpLabelLines.NA4, ImpLabelLines.NA5, ImpLabelLines.NA6, ImpLabelLines.NA7" & _
"FROM ImpLabelLines" & _
"WHERE (((ImpLabelLines.NA7) is Not Null And (ImpLabelLines.NA7)<>""));"
Many thanks for some direction here,
alr
_____________________________________
If a large part of intelligence is the ability to generalize, it is ironic that a large part of what we call wisdom is the ability not to generalize.
I am trying to move many queries to be operated by command buttons on a form by using the DoCmd.runSQL command. Most of them work just fine but several have syntax problems.
When the command button is clicked an error message reads:
Syntax error (missing operator) in query expression "ImpLabelLines.NA7FROM ImpLabelLinesWhere (((ImpLabelLines(ImpLabelLines.NA7 <>"));'
The problems seem to be in complex WHERE clauses that are filled with (not isnull and <> ""). Is there a syntax difference for Access SQL and SQL in VBA code?
I tried using the SQL statement directly with the runSQL and putting the SQL all on one line and there is no difference.
I could not find a way to run named queries but this might solve the problem as well. The full statement is below:
Sql1a = "INSERT INTO WkDt ( IdSource, NAME1, NAME2, NAME3, NAME4, ADDR1, ADDR2, CSZ )" & _
"SELECT ImpLabelLines.IdSource, ImpLabelLines.NA1, ImpLabelLines.NA2, ImpLabelLines.NA3, ImpLabelLines.NA4, ImpLabelLines.NA5, ImpLabelLines.NA6, ImpLabelLines.NA7" & _
"FROM ImpLabelLines" & _
"WHERE (((ImpLabelLines.NA7) is Not Null And (ImpLabelLines.NA7)<>""));"
Many thanks for some direction here,
alr
_____________________________________
If a large part of intelligence is the ability to generalize, it is ironic that a large part of what we call wisdom is the ability not to generalize.