Help with Select statement

A

Ayo

This select statement is not working. I have used it many times before, it is
in a Row Source property for a ComboBox.
"SELECT DISTINCT [Requesting Cost Cent] FROM Actuals;"

Is there something I am doing wrong? The same exact syntax below, in another
database works fine:
"SELECT DISTINCT (tblSiteList.[Site Id]) FROM tblSiteList; "
 
J

Jeff Boyce

We aren't there. We can't tell which version of Access you are using. We
don't know where your data is located (?same file, a separate back-end, a
back-end not even in Access?)

When I read your two examples, I (literally) do NOT see the same syntax.
The second example uses the tablename to fully qualify the field.

Have you tried doing this as a query, in design view, to see what Access
comes up with as a SELECT statement?

(Note: Access sometimes gets 'a chickenbone stuck in its throat' and you
can't see that ... consider starting over with a query in design view to see
if you can get it working. If it does, swap it out for what isn't
working...)

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
A

Ayo

It's not returning any records. There are no error messages.

Jerry Whittle said:
"not working"? How? Error message? Not returning any records?
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


Ayo said:
This select statement is not working. I have used it many times before, it is
in a Row Source property for a ComboBox.
"SELECT DISTINCT [Requesting Cost Cent] FROM Actuals;"

Is there something I am doing wrong? The same exact syntax below, in another
database works fine:
"SELECT DISTINCT (tblSiteList.[Site Id]) FROM tblSiteList; "
 
A

Ayo

I just trid using "SELECT DISTINCT Actuals.[Requesting Cost Cent] FROM Actuals
ORDER BY Actuals.[Requesting Cost Cent];" from the Query. The Query worked
fine but when I used it in my Combox, I still didn't get any records. By the
way I am using Access 2007. I currently have only one table so far and that
is all I am using.


Jeff Boyce said:
We aren't there. We can't tell which version of Access you are using. We
don't know where your data is located (?same file, a separate back-end, a
back-end not even in Access?)

When I read your two examples, I (literally) do NOT see the same syntax.
The second example uses the tablename to fully qualify the field.

Have you tried doing this as a query, in design view, to see what Access
comes up with as a SELECT statement?

(Note: Access sometimes gets 'a chickenbone stuck in its throat' and you
can't see that ... consider starting over with a query in design view to see
if you can get it working. If it does, swap it out for what isn't
working...)

Regards

Jeff Boyce
Microsoft Office/Access MVP


Ayo said:
This select statement is not working. I have used it many times before, it
is
in a Row Source property for a ComboBox.
"SELECT DISTINCT [Requesting Cost Cent] FROM Actuals;"

Is there something I am doing wrong? The same exact syntax below, in
another
database works fine:
"SELECT DISTINCT (tblSiteList.[Site Id]) FROM tblSiteList; "
 
J

Jerry Whittle

If you run the SQL as a plain query, does it return records then? If not,
something is wrong with the query. Check the table and fields for proper
names and having appropriate data in them.

If the query returns records, open up the form in design view. Click on the
combo box and bring up its properties. In the Data tab, the the query/SQL
statement the Row Source? If not, there's the problem. If so, is the Bound
Column 1? As you only have one column returned, it should be. Next go to the
Format tab. The Column Count should only be 1 and the Column and List Width
Widths should be Auto or something like 2". If it's 0" or very small, you
might not see the data.
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


Ayo said:
It's not returning any records. There are no error messages.

Jerry Whittle said:
"not working"? How? Error message? Not returning any records?
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


Ayo said:
This select statement is not working. I have used it many times before, it is
in a Row Source property for a ComboBox.
"SELECT DISTINCT [Requesting Cost Cent] FROM Actuals;"

Is there something I am doing wrong? The same exact syntax below, in another
database works fine:
"SELECT DISTINCT (tblSiteList.[Site Id]) FROM tblSiteList; "
 
A

Ayo

Thank you so much Jerry. It was the properties in the format tab that was the
problem.

Jerry Whittle said:
If you run the SQL as a plain query, does it return records then? If not,
something is wrong with the query. Check the table and fields for proper
names and having appropriate data in them.

If the query returns records, open up the form in design view. Click on the
combo box and bring up its properties. In the Data tab, the the query/SQL
statement the Row Source? If not, there's the problem. If so, is the Bound
Column 1? As you only have one column returned, it should be. Next go to the
Format tab. The Column Count should only be 1 and the Column and List Width
Widths should be Auto or something like 2". If it's 0" or very small, you
might not see the data.
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


Ayo said:
It's not returning any records. There are no error messages.

Jerry Whittle said:
"not working"? How? Error message? Not returning any records?
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


:

This select statement is not working. I have used it many times before, it is
in a Row Source property for a ComboBox.
"SELECT DISTINCT [Requesting Cost Cent] FROM Actuals;"

Is there something I am doing wrong? The same exact syntax below, in another
database works fine:
"SELECT DISTINCT (tblSiteList.[Site Id]) FROM tblSiteList; "
 

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

Top