Syntax Error in Sub Query

G

Guest

I have the following sub query in my query which is trying to calculate a
base based on two critieria within the same table that is used for the main
query.

Base: (SELECT Small Busiiness Activity Detail.Spent FROM Small Business
Activity Detail WHERE Minority Indicator Categories = "sb" or "lb")

I keep getting syntax error message. What am I doing wrong, please?

Rob
 
G

Guest

Looking at your query i see a lot of spaces in the table and fieldname. Try
placing your tablename and fieldname between [ ] then try again.

So it should look like:
[Small Busiiness Activity Detail].spent

hth
 
M

Marshall Barton

Rob said:
I have the following sub query in my query which is trying to calculate a
base based on two critieria within the same table that is used for the main
query.

Base: (SELECT Small Busiiness Activity Detail.Spent FROM Small Business
Activity Detail WHERE Minority Indicator Categories = "sb" or "lb")

I keep getting syntax error message. What am I doing wrong, please?


Names with spaces or other funky characters must be enclosed
in [ ]

Base: (SELECT [Small Busiiness Activity Detail].Spent
FROM [Small Business Activity Detail]
WHERE [Minority Indicator Categories] = "sb"
or [Minority Indicator Categories] = "lb")
 
G

Guest

I took your advice and am still having the same problem, i.e. my subquery has
a syntax error. This is where I am thus far:

Base: (SELECT [Small Busiiness Activity Detail].[Spent] WHERE [Small
Business Activity Detail].[Minority Indicator Categories] = "sb" or "lb")

Any help would be greatly appreciated.

Rob


Maurice said:
Looking at your query i see a lot of spaces in the table and fieldname. Try
placing your tablename and fieldname between [ ] then try again.

So it should look like:
[Small Busiiness Activity Detail].spent

hth
--
Maurice Ausum


Rob said:
I have the following sub query in my query which is trying to calculate a
base based on two critieria within the same table that is used for the main
query.

Base: (SELECT Small Busiiness Activity Detail.Spent FROM Small Business
Activity Detail WHERE Minority Indicator Categories = "sb" or "lb")

I keep getting syntax error message. What am I doing wrong, please?

Rob
 
J

John Spencer

That may error also since it looks as if this is being used a calculated
column.

Perhaps the user need to use a SUM predicate around spent or Min or Max
or ???. This query could obviously return more than one record.



'====================================================
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================


Marshall said:
Rob said:
I have the following sub query in my query which is trying to calculate a
base based on two critieria within the same table that is used for the main
query.

Base: (SELECT Small Busiiness Activity Detail.Spent FROM Small Business
Activity Detail WHERE Minority Indicator Categories = "sb" or "lb")

I keep getting syntax error message. What am I doing wrong, please?


Names with spaces or other funky characters must be enclosed
in [ ]

Base: (SELECT [Small Busiiness Activity Detail].Spent
FROM [Small Business Activity Detail]
WHERE [Minority Indicator Categories] = "sb"
or [Minority Indicator Categories] = "lb")
 
C

Chris2

Rob said:
I took your advice and am still having the same problem, i.e. my subquery has
a syntax error. This is where I am thus far:

Base: (SELECT [Small Busiiness Activity Detail].[Spent] WHERE [Small
Business Activity Detail].[Minority Indicator Categories] = "sb" or "lb")

Any help would be greatly appreciated.

Rob

Rob,

Your second subquery has no FROM clause. It won't work without one.

Try:

Base: (SELECT [Small Busiiness Activity Detail].[Spent] FROM [Small Business
Activity Detail] WHERE [Small Business Activity Detail].[Minority Indicator Categories] =
"sb" or "lb")

Your first subquery in your original post:

Base: (SELECT Small Busiiness Activity Detail.Spent FROM Small Business
Activity Detail WHERE Minority Indicator Categories = "sb" or "lb")

Did have a FROM clause.

As far as I can tell, you corrected one error, a lack of [], and then accidentally deleted
the FROM clause in the process.

I also notice that Business appears to be misspelled as Busiiness in both subqueries, and
if that is a misspelling, that will also cause and error.


Comments:

Avoid spaces or special characters in the names of tables, columns, forms, controls,
reports, and modules.


Sincerely,

Chris O.
 
D

Douglas J. Steele

Chris2 said:
Rob said:
I took your advice and am still having the same problem, i.e. my subquery
has
a syntax error. This is where I am thus far:

Base: (SELECT [Small Busiiness Activity Detail].[Spent] WHERE [Small
Business Activity Detail].[Minority Indicator Categories] = "sb" or "lb")

Rob,

Your second subquery has no FROM clause. It won't work without one.

Try:

Base: (SELECT [Small Busiiness Activity Detail].[Spent] FROM [Small
Business
Activity Detail] WHERE [Small Business Activity Detail].[Minority
Indicator Categories] =
"sb" or "lb")

Your use of "or" is incorrect. It needs to be either

Base: (SELECT [Small Busiiness Activity Detail].[Spent] FROM [Small Business
Activity Detail] WHERE [Small Business Activity Detail].[Minority Indicator
Categories] =
"sb" or [Small Business Activity Detail].[Minority Indicator Categories] =
"lb")

or

Base: (SELECT [Small Busiiness Activity Detail].[Spent] FROM [Small Business
Activity Detail] WHERE [Small Business Activity Detail].[Minority Indicator
Categories] IN ("sb" or "lb"))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top