Easy (I think) Drop Down Box Question

T

Tanya Lee

This question has probably been asked a hundred times, but I have searched
and searched and can't find the answer in here or in Access help.

How do I allow data entry in myy drop down box? (So people can add to it
without going into the table).

Thank you!
Tanya Lee
 
A

Allen Browne

If the data that you see in the combo is actually the data in the table
(i.e. the combos does not have a hidden bound column), you can use its
NotInList event procedure to programmatically add the data to the table.
Details in:
NotInList: Adding values to lookup tables
at:
http://allenbrowne.com/ser-27.html

If the combo does have a hidden bound column, or if there are other fields
you need to add to the lookup table as well, you might consider using the
DblClick event of the combo to open the form where these entries are made.
That's just a matter of using the OpenForm action/method in the DblClick
event. But once the new entry is added, you need to Requery the combo so it
learns about the new entry. Use the AfterUpdate event of the entry form. The
line of code would be:
Forms.Form1.Combo1.Requery
 
S

Sprinks

Tanya,

You may either set the Limit to List property to No, or set it to Yes and
use the On Not In List event to run a procedure that will allow the addition
to be made. I recommend the latter as it makes the user confirm that he
truly want to add the item to the list.

See the following link for code:

http://www.functionx.com/vbaccess/articles/notinlist.htm

Sprinks
 
T

Tanya Lee

Thank you, I will look at both suggestions and see which one works for me.
Tanya Lee
 
T

Tanya Lee

I went to your webpage and followed your instructions but it won't work for
me. Can you explain the purpose of creating the module in Step 1? I don't see
how that module is used again (I'm unfamiliar with modules and what they do).
Am I missing something I'm supposed to do?

My dropdown box will now allow me enter a new item, but it does not save it
to the table.

Thank you again!
 
A

Allen Browne

We suggest that you save the function in a standard module, so it can be
used for any combo on any form in the database.

The function saved in that module is called by the line of code in step 5.
 
Top