Using inputbox to add new field to combobox

F

Fred

Hi, I'm having some trouble on this matter..

I have some combobox with a few fields previously added and one of the is
called "Add new park".. i'm trying to create a code that when this option is
chosen opens a inputbox so the user can fill it with the new field he wants
to add..
i imagine it starts with..
private Sub Combo_Exit (Cancel as Integer)
dim i as double
if Combo.text = "Add new park" then
msgbox "Sure you want to add?"
i = inputbox ("Write new park name", "Park", "")
...............
i cant figure the next code on this routine.. to add it to the item list of
the combobox

Can you help me please...
Thanks
 
F

fredg

Hi, I'm having some trouble on this matter..

I have some combobox with a few fields previously added and one of the is
called "Add new park".. i'm trying to create a code that when this option is
chosen opens a inputbox so the user can fill it with the new field he wants
to add..
i imagine it starts with..
private Sub Combo_Exit (Cancel as Integer)
dim i as double
if Combo.text = "Add new park" then
msgbox "Sure you want to add?"
i = inputbox ("Write new park name", "Park", "")
..............
i cant figure the next code on this routine.. to add it to the item list of
the combobox

Can you help me please...
Thanks

Where does the combo get it's values from? A table?
There is a simpler way to add a new value.
You can remove that "Add New Park" from your current list.

Set the Combo Box LimitToList property to Yes.

Code the Combo's NotInList event:

If MsgBox("The Item Entered is not in database, would you like to add
it?", vbYesNo) = vbYes Then

CurrentDb.Execute "INSERT INTO TableName(FieldName) Select " &
Chr(34) & NewData & Chr(34) & ";", dbFailOnError

Response = acDataErrAdded
End If

Anytime the user enters a value not already in the list, he/she will
be prompted to add the new value. Click Yes and the value will be
added automatically. Click No and the value will not be added.
 
F

Fred

Thanks.. The values listed are predifined.. I really wanted to do it the way
i told you.. I want it to identify the "add new park" option and then open a
inputbox so i can add the field.. can you help me with that.. it shouldn't be
that different..i think..
Thanks for your attention
Nuno

"fredg" escreveu:
 

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