Add item to Dropdown combo box (1 Viewer)

smiler44

Registered User.
Local time
Today, 19:18
Joined
Jul 15, 2008
Messages
641
When my form loads it loads the dropdown combo box with a list of colours that exist in a database. I may want to use a colour that does not yet appear in the database. In this case I just over type what ever text is displayed in the combo box with the colour I want to use and carry on.
How can I add this new colour to the dropdown combo box while I'm working without having to check against the database? When the form next loads it will check against the database and load the colours found there.

thank you in advance
smiler44
 

namliam

The Mailman - AWF VIP
Local time
Today, 20:18
Joined
Aug 11, 2003
Messages
11,696
Check out the "notinlist" event of the combobox, check the help and google should provide you some starting samples.
 

smiler44

Registered User.
Local time
Today, 19:18
Joined
Jul 15, 2008
Messages
641
namliam,
thank you. found quite a bit via Google but cant make any of it work so I'm sure I'm doing something wrong. how do I call the following routine and where should it go?
Hopefully if someone can tell me how to activate the following code I will be ok?


Code:
Private Sub Acct_Name_Entry_NotInList(newdata As String, Response As Integer)
Response = acDataErrContinue
Call Acct_Name_Not_Found(newdata)
End Sub
 

Mr. B

"Doctor Access"
Local time
Today, 13:18
Joined
May 20, 2009
Messages
1,932
When my form loads it loads the dropdown combo box with a list of colours that exist in a database. I may want to use a colour that does not yet appear in the database. In this case I just over type what ever text is displayed in the combo box with the colour I want to use and carry on.
How can I add this new colour to the dropdown combo box while I'm working without having to check against the database? When the form next loads it will check against the database and load the colours found there.

thank you in advance
smiler44

I would appear to me that the the issue here is in the statement: "list of colors that exist in a database." From your post I am assuming that you are returning a unique list of existing color values from the existing data.

The "OnNotInList" event and some code can add a new item to a list when you are pulling the data from a refernce table, however, when you are returning a unique list of values from an existing list, you cannot just simply add a new value because you would have to add the new value to the same table from which you are pulling the list. If you can find a way to manually create a new record in your table and manually enter a new color, then the next time the combo box is loaded, the new value will be available. If you want the type of functionality you are describing where you can add new color values on the fly, you will need to create a seperate table of available colors. Then you can add a new color to that table at will.
 

smiler44

Registered User.
Local time
Today, 19:18
Joined
Jul 15, 2008
Messages
641
Thanks Mr.B. I could reload the combo box but thought I may be able to save a bit of time if I could add direct to the list.

smiler44
 

Mr. B

"Doctor Access"
Local time
Today, 13:18
Joined
May 20, 2009
Messages
1,932
Just one thought: You could set the Limit to List property to no and this would allow any value to be added to the list. This would require that you evaluate each value entered before allowing it to be committed to the database but it might be a possibility. Just a thought.
 

namliam

The Mailman - AWF VIP
Local time
Today, 20:18
Joined
Aug 11, 2003
Messages
11,696
Well for a list of states / countries if you want to include all... I would add all and add a "visible" flag/field to it.
The combo would only show those that are "visible" true, and when not in list check for a visible No value on that. If found, make true and continue, if not found error out.
 

Users who are viewing this thread

Top Bottom