Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combobox (style 0) not allowing non-listed input 1

Status
Not open for further replies.

TGrahmann

Programmer
Feb 19, 2015
43
US
Hello, I am having an issue with Style 0 Comboboxes where when a user enters something in the box that is not a contained item, it will not store to tables or so on when it is time to use the value of the object. Any help is greatly appreciated!
Thanks!
 
I assume you expect what you type in the Combobox should be stored into the rowsource. That's not happening.
Every control saves to it's controlsource (the grid is an exception, but within it, the columns all maintain their controlsource, too).

As you see the Combobox has two data sources. The data source to define its items is the rowsource. The controlsource both determines what item is picked and where the picked item or entered text is saved.

The entered text becomes the value of the combobox, just like the picked item text. Unless you bind the controlsource to an integer foreign key field, that won't work with a dropdown combo style combobox.

Anyway, the combobox never maintains the items. You can have a textbox with autocomplete feature, if you want that. Or program the adding of items yourself.

Bye, Olaf.
 
What you are seeing is normal. It is how Stype 0 combo boxes are designed to work.

It might help to keep the following in mind:

If the user picks an existing value from the list, the Value property will contain that value. If the combo has more than one column, the Boundcolumn property indicates the column from which the Value is taken. The DisplayValue property always contains the value from the first column.

If the user types in a new value, the Value property will be empty; DisplayValue will contain the value that the user types.

In the second case, you need to write code to update the underlying table (or take whatever other action is appropriate). If that action results in adding the new value to the list, you should call the combo box's Requery method in order for the list to be updated.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top