A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Unique values in a combo box



 
 
Thread Tools Display Modes
  #1  
Old October 19th, 2009, 05:08 PM posted to microsoft.public.access.forms
dannie
external usenet poster
 
Posts: 25
Default Unique values in a combo box

I have a form that displays my records stored in a table "inspectionsDI" I
have a listbox in the form that displays all the records for easy to find
access. I will have over 400 records so I want to make a combo box that will
filter my listbox according to a value stored in the table. I can make it so
that the combo box displays all the values but there are many duplicates, how
do I make the combo box show only each unique value once? Or is there are
better way to approach this problem?
  #2  
Old October 19th, 2009, 05:37 PM posted to microsoft.public.access.forms
Mr. B[_4_]
external usenet poster
 
Posts: 171
Default Unique values in a combo box

dannie,

Design a query to use as the record source for your combo box. One of the
properties that you can set for the query is "unique values". Set this
property to true for your query.

-----
HTH
Mr. B
http://www.askdoctoraccess.com/
Doctor Access Downloads Page:
http://www.askdoctoraccess.com/DownloadPage.htm


"dannie" wrote:

I have a form that displays my records stored in a table "inspectionsDI" I
have a listbox in the form that displays all the records for easy to find
access. I will have over 400 records so I want to make a combo box that will
filter my listbox according to a value stored in the table. I can make it so
that the combo box displays all the values but there are many duplicates, how
do I make the combo box show only each unique value once? Or is there are
better way to approach this problem?

  #3  
Old October 19th, 2009, 05:40 PM posted to microsoft.public.access.forms
Jeff Boyce
external usenet poster
 
Posts: 8,621
Default Unique values in a combo box

Having a listbox with "over 400" records is more than most users will put up
with. g

Adding a combobox to narrow the list down is a way to reduce the number of
rows the users have to work through ... BUT!

If you have a combobox to help select the right record, why bother with the
listbox at all? Your combobox would take up less room on the form and would
still give your users a way to select the right record.

JOPO (just one person's opinion)

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or psuedocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.

"dannie" wrote in message
...
I have a form that displays my records stored in a table "inspectionsDI" I
have a listbox in the form that displays all the records for easy to find
access. I will have over 400 records so I want to make a combo box that
will
filter my listbox according to a value stored in the table. I can make it
so
that the combo box displays all the values but there are many duplicates,
how
do I make the combo box show only each unique value once? Or is there are
better way to approach this problem?



  #4  
Old October 19th, 2009, 05:44 PM posted to microsoft.public.access.forms
fredg
external usenet poster
 
Posts: 4,386
Default Unique values in a combo box

On Mon, 19 Oct 2009 09:08:11 -0700, dannie wrote:

I have a form that displays my records stored in a table "inspectionsDI" I
have a listbox in the form that displays all the records for easy to find
access. I will have over 400 records so I want to make a combo box that will
filter my listbox according to a value stored in the table. I can make it so
that the combo box displays all the values but there are many duplicates, how
do I make the combo box show only each unique value once? Or is there are
better way to approach this problem?


I'm not sure I follow what you want, but I think .....

Create a query to display just the distinct records.

Select Distinct MyTable.[FieldName] from MyTable;

use that as the Combo Rowsource.
(Look up the Distinct keyword in SQL help.)

Then, to filter the List Box, code the Combo Box AfterUpdate event
(all on one line):

Me.ListBoxName.Rowsource = "Select inpsectionDI.FieldName1,
inspectionDI.FieldName2 from inspectionDI Where inspectionDI.FieldName
= """ & Me.ComboName & """;"

The coding above assumes the value in MyTable.FieldName is Text
datatype.
If in fact it is Number datatype then use:

Me.ListBoxName.Rowsource = "Select .... etc ..... Where
inspectionDI.FieldName = "& Me.ComboName


Change all of the control, field, and table names to whatever your
actual names are.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 04:30 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.