Adding all to combo

D

d9pierce

Hi everyone,
How does one add "ALL" to a bound cbo box?

Cbo has two columns, bound to 1
RegionID
RegionName

Any Suggestions?
Thanks
Dave
 
D

d9pierce

It's easy enough to add All to the list:
http://www.mvps.org/access/forms/frm0043.htm

What's more difficult is making sense of interpreting it once you get it in
there.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users -http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.








- Show quoted text -

Hi and thanks,
You are right on comment but got it! :)
Thanks again,
Dave
 
D

d9pierce

It's easy enough to add All to the list:
http://www.mvps.org/access/forms/frm0043.htm

What's more difficult is making sense of interpreting it once you get it in
there.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users -http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.








- Show quoted text -

Hi again,
After following the link and reading it over good, I guess your answer
is you cannot do this unless I assign some sort of UID or a choose a
different primary Key for this table?

For example, if your combo's RowSource is this SQL statement
"(AND IT IS)"

SELECT CustomerID, CompanyName FROM Customers ORDER BY CustomerID;

you can then easily add "(All)" as the first choice. Also, if
CustomerID is the bound field but it's width is set to zero (so that
the user only sees CompanyName), you can store a NULL (if the bound
field is not the primary key of the table), or someother value in the
bound field.

SELECT CustomerID, CompanyName FROM Customers UNION Select Null as
AllChoice , "(All)" as Bogus From Customers ORDER BY CustomerID;

tHIS WOULD WORK FINE IN THE EVENT ONE DIDNT HAVE THE PRIMARY KEY
ASSIGNED TO THE BOUND COLUMN. WHAT THIS DOESNT SHOW IS WHAT IF THE
BOUND COLUMN IS THE PRIMARY KEY WHICH IN THIS ISNSTANCE IS MOST LIKELY
TRUE MOST OF THE TIME. IS THERE ANY DOCUMENTATION ANYWHERE THAT WOULD
EXPLAIN THE WHAT IF?
THANKS,
DAVE
 
A

Allen Browne

If the combo is bound to a primary key (or any required field), then the
attempt to store the Null there is doomed to fail.
 
D

Douglas J. Steele

How are you using the combo box?

If, for example, you're using it as a parameter in a query, you'd change the
WHERE clause from

WHERE FIeld1 = Forms!MyForm!MyComboBox

to

WHERE (FIeld1 = Forms!MyForm!MyComboBox OR Forms!MyForm!MyComboBox IS NULL)

If you're referring to the combo box in VBA, you use the IsNull function.
 
D

d9pierce

How are you using the combo box?

If, for example, you're using it as a parameter in a query, you'd change the
WHERE clause from

WHERE FIeld1 = Forms!MyForm!MyComboBox

to

WHERE (FIeld1 = Forms!MyForm!MyComboBox OR Forms!MyForm!MyComboBox IS NULL)

If you're referring to the combo box in VBA, you use the IsNull function.

--
Doug Steele, Microsoft Access MVPhttp://I.Am/DougSteele
(no e-mails, please!)













- Show quoted text -

The control or cbo is table/Query with record source set to Region.
The form is based on a query!
 
D

Douglas J. Steele

Sorry, you haven't answered the question. How are you using the combo box?
Are you trying to use it for Search purposes, or are you trying to use it to
add records to a table using the combo box as input? If you're trying to use
it for input, giving a choice of All really makes no sense.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


The control or cbo is table/Query with record source set to Region.
The form is based on a query!
 
Top