Combo Box with Updateable Value List

R

=Ray=

I want to have a combo box on my form that allows the user to enter data that
is not an item in the value list, and where the combo box has as its value
list, all the different values in a field. (The purpose being to minimize
entry error, as in misspellings, etc. so that a previously entered value can
be easily reentered with the same spelling, but where new values may still be
entered)

So for example, when the tables are empty, I have an empty combo box, and
you can enter whatever you want (text field). Then when you start to enter
the next record, the value you entered for the first record would appear as
an item in the combo box, but where you may also enter a new value. If the
same value is used on multiple records, it should still only appear once in
the combo box.

Is there any way I can accomplish this? If I need to do some coding, that is
fine. The database will not likely ever get exceedingly large (probably never
more than 1000 records), but I'd prefer not to use a loop with VBA to go
through all the records in generating the value list.

Thanks for any help,
Ray
 
K

Klatuu

This would be better accomplished with using a Table/Query row source instead
of a value list. Then for the row source, use a query that will return one
occurance of each value currently in the form's record source.

SELECT DISTINCT [FieldName] FROM TableName ORDER BY [FieldName];

Set the combo's Limit To List property to No so you can add a new value to
the field.

The last thing to do is add the new value to the combo by requerying it use
the form's After Update event:

Me.MyCombo.Requery
 
R

=Ray=

Thank you very much. That did exactly what I need.
Ray

Klatuu said:
This would be better accomplished with using a Table/Query row source instead
of a value list. Then for the row source, use a query that will return one
occurance of each value currently in the form's record source.

SELECT DISTINCT [FieldName] FROM TableName ORDER BY [FieldName];

Set the combo's Limit To List property to No so you can add a new value to
the field.

The last thing to do is add the new value to the combo by requerying it use
the form's After Update event:

Me.MyCombo.Requery


--
Dave Hargis, Microsoft Access MVP


=Ray= said:
I want to have a combo box on my form that allows the user to enter data that
is not an item in the value list, and where the combo box has as its value
list, all the different values in a field. (The purpose being to minimize
entry error, as in misspellings, etc. so that a previously entered value can
be easily reentered with the same spelling, but where new values may still be
entered)

So for example, when the tables are empty, I have an empty combo box, and
you can enter whatever you want (text field). Then when you start to enter
the next record, the value you entered for the first record would appear as
an item in the combo box, but where you may also enter a new value. If the
same value is used on multiple records, it should still only appear once in
the combo box.

Is there any way I can accomplish this? If I need to do some coding, that is
fine. The database will not likely ever get exceedingly large (probably never
more than 1000 records), but I'd prefer not to use a loop with VBA to go
through all the records in generating the value list.

Thanks for any help,
Ray
 

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