Ok looked at the links, had 2 BAD names changed them
"Row Source of the combo box likely needs to be "SELECT DISTINCT
Table1.[Number] FROM Table1 ORDER BY Table1.[Number]" "
when I put that in, changed Number to MyData, I got nothing in the
combo
box
this is what I have in the row source
SELECT Table1.ID, Table1.[MyData] FROM Table1;
Think I need to get this working before I try the add an "all"
selection
to
your combo box
Looking like I might just give up on Access and go back to using Excel
!
Douglas, I will have a look at that, but after some more testing it looks
like it does not work after all, the query is picking up what position
the
item is in, in the combo box not what it is, so if I pick the first item
in
the box the query is looking for a 1, if I pick the next item down it is
looking for a 2.
So if the items in the box are cat, dog, horse if I pick dog the criteria
looks for 2.????
Maybe I just need DETAIL instructions on how to use a drop down box
for a
query criteria
off to look at the links you gave
Thanks
--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003
First, I was attempting to address your complaint that "the combo
box
shows
all the numbers like 3 1's 4 2's 3 3's". The SQL you've posted is
likely
your "real" query, not the row source for your combo box: I wasn't
suggesting using DISTINCT for that query.
Presumably you've got different values of ID and Name corresponding to
the
same values of Number. That's what I was referring to when I said "Just
make
sure that you've only got the necessary fields in the query so that
UniqueValues makes sense". The query you're using for the Row Source of
the
combo box likely needs to be "SELECT DISTINCT Table1.[Number] FROM
Table1
ORDER BY Table1.[Number]", unless you've got a second table that
only
holds
one row for each unique value of Number. (Incidentally, I'd
recommend
very
strongly not using Name and Number as field names: those are
reserved
words,
and should never be used for your own purposes. For more details about
what
words are "bad", see what Allen Browne has at
http://www.allenbrowne.com/AppIssueBadWord.html)
Since you've gone in to the SQL and made your changes, there's no
reason
to
worry about the properties of the query: it's simpy another way of
accomplishing the same thing. For the record, though, to get at the
Properties window for the query itself, click in the upper part of the
graphic interface (where the tables are) to get the properties of
the
query.
(It should say "Query Properties" as the caption for the window)
To add an "all" selection to your combo box, see
http://www.mvps.org/access/forms/frm0043.htm at "The Access Web". Note
that
your underlying query would then have to be changed to something like:
SELECT DISTINCT Table1.ID, Table1.Name, Table1.Number
FROM Table1
WHERE (((Table1.Number)=[Forms]![Table1form]![MyComboBox]))
OR [Forms]![Table1form]![MyComboBox] = "All"
I don't see any reason why your query shouldn't work with "higher"
entries
in the combo box.
--
Doug Steele, Microsoft Access MVP
(no private e-mails, please)
Douglas, changed select to select distinct, I get the same thing,
here
is
the code that I am seeing
SELECT DISTINCT Table1.ID, Table1.Name, Table1.Number
FROM Table1
WHERE (((Table1.Number)=[Forms]![Table1form]![MyComboBox]));
how do I see the properties for the query, looks like I am seeing
only
the
field properties, I don't see an option for unique
Thanks for your help, but as I said I am very new to Access so if you
could
break it down a little more would be great
--
message
Create a query that uses SELECT DISTINCT rather than SELECT, and use
that
as
the Row Source for your combo box.
You can either go into the SQL view of the query (when the
query's
open,
look under the View menu and select SQL view), or you can look at
the
Properties of the query: you should have choices for "UniqueValues"
and
"UniqueRecords": you want UniqueValues (make sure you're looking at
the
properties for the query itself, not for one of the fields in the
query).
Just make sure that you've only got the necessary fields in the
query
so
that UniqueValues makes sense.
--
Doug Steele, Microsoft Access MVP
(no private e-mails, please)
Very newbie here, only started using Access 2 days ago,
I have managed to make a very simple table to use for testing,
made
a
query
and report, even managed to make a combo box on a form and used it
for
the
query criteria and got it all to work, almost all, the table I
made
just
has
some names in a column and numbers in the next column 1, 2, 3, the
combo
box
shows all the numbers like 3 1's 4 2's 3 3's if I pick a 1,
2,
or
3
from
the top of the list everything works fine, but if I pick one of
the
numbers
after the first 3 I get a query or report with no data.
So now the questions,
How do I fix this?
Is there a way to only show unique valves in the combo box?
Or am I going about this the wrong way?
This seams like a lot of work just to get a drop down box for a
query
criteria, is there an easier way?
Also any links to a file like this to download so I could take
a
look
at
it
would be appreciated.
Almost forgot, is there a way to have a "show all" in the combo
box?
Thanks
Using Access 2002