The Rookie Rides Again - Data Entry in a ComboBox

Hi there,

I’m trying to duplicate a behavior from my old Access application within the Servoy environment. Here’s what it does now…

  1. On a form, displays a field that is a drop-down list.
  2. The drop down list is filled from a table in my database.
  3. In a configuration area, the user can designate on entry from the source table to be the default value.
  4. A user can select an item from the drop down list, or type in their own value, in which case the system will recognize it as not a part of the drop down list and ask if the user would like to add this to the table.
  5. Whatever finally ends up in the field becomes the data that is loaded into the record in the database.

The behavior ends up looking like this…

  1. When you open the form (let’s say to build a new record), the field in question has a value in it and the drop-down arrow as well.
  2. You can just leave the default value, or you can select another from the table or you can type in something new.
  3. If you type something new, the system will sense this and display a message such as “This is a new value. Would you like to add it to the table?”

So far, I’ve been able to do this…

  1. I can create the field on a form and set the DisplayType as “COMBOBOX”.
  2. I can create a valuelist based on a table that will fill the combobox.
  3. In a separate form, I can edit the valuelist’s table to add new data as required, but I want to do this right from the Combobox.

I’ve checked the developer’s guide as well as Adrian McGilly’s Beginner Guide. There was a discussion here back in May on filling in a default value in a Combobox, but it’s unclear to me whether or not a solution was actually agreed on.

Any thoughts on how I might go about doing this?

As always, thanks for any thoughts you might have.

Ron

This is just an idea:

The value list may also be the product of a SQL statement. Hence you can add a record from the value list as product of a select statement with ‘DISTINCT.’ The the value list will only allow you to retrieves unique data entry values, but you’ll be able to insert in that column records with existing or different values. Once a record is committed, that new value should appear in the value list (which is product of a select statement with DISTINCT.)

For example, you want the user to use already known last names (to reduce misspellings, for instance). You’ll create the value list from a statement like:

SELECT DISTINCT last_name FROM User_Names

The value list will show all known last names, and by using ‘type ahead(*),’ the user can reduce the list accordingly. I guess, you get the idea. If the last name does not exist, the record will be created by tying it in.

Keep in mind that here you won’t really need a different table (as in this example), but it can also work in a one-to-one tables relationship.

If you think that this approach can help you, check these videos in the Servoy University Website (http://www.servoyuniversity.com/)

The video tutorial I’d see is at: Servoy University - Training Videos and Tutorials - Certification

JC


(*) Check this open source plugin for those situations where a combo-box or contextual menu are not enough: Overview - JSListPicker module - ServoyForge

Hi JC,

Thanks a lot; I’ll take a look at that further. The link to the video at Servoy U isn’t working as you expect, I think. But, I have a subscription to Servoy U., so can you just tell me which video topic it’s in? I can take it from there (I’m only about 5 videos into the series so far :-)).

Thanks again and have a good evening.

Ron

RonG:
The link to the video at Servoy U isn’t working as you expect, I think. But, I have a subscription to Servoy U., so can you just tell me which video topic it’s in? I can take it from there (I’m only about 5 videos into the series so far :-)).

Tutorial: Advanced Valuelists
Author: Bob Cusick

Your welcome. Check your post again. Somebody else might have another idea.

JC

Using Servoy 5.2 - I just noticed that if you want a value list derived from a column of a table, you don’t need to derive it from SELECT DISTINCT. Servoy will provide you with the list of unique values from the selected column of the specified table. That easy!

JC