Normal Topic Question about populating combo boxes (Read 1029 times)
SmartCarry
Member
*
Offline



Posts: 3
Joined: Mar 6th, 2012
Question about populating combo boxes
Mar 7th, 2012 at 7:50pm
Print Post Print Post  
Hi,
I'm a new Sesame user with a basic question. We use Sesame for invoicing but I'd like to add a little more functionality to make the process efficient. We sell products that depend, in order of importance, upon a Manufacturer, then Model, then Size, to finally display the appropriate product. How can I populate each combo box to display the appropriate data as the user moves through them? My goal is to have a subform displaying the data in Retrieve mode, with command buttons to Update or Add.

I saw one older example related to this in the Programming Section (I can't post the link) but I'm not getting the expected results.

Thanks in advance for any assistance.
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Question about populating combo boxes
Reply #1 - Mar 8th, 2012 at 4:51pm
Print Post Print Post  
In the first combo, put some code in the on change or on immediate change event that populates the second combo based on the value selected from the first. In the second combo, do the same for the third. etc.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Rick_R
Full Member
***
Offline



Posts: 243
Joined: Jan 29th, 2010
Re: Question about populating combo boxes
Reply #2 - Mar 8th, 2012 at 9:18pm
Print Post Print Post  
Check XLookupAll().  It returns all matches as a semi-colon delimited string, i.e., essentially:

Manufacturer = "ABC-Company"
AllModels = xlookupall(Manufacturer, "Products" [etc])

AllModels will come back as "ABC123;ABC345;ABC456"

Then the combo box options can be populated using that string.
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Question about populating combo boxes
Reply #3 - Mar 8th, 2012 at 10:03pm
Print Post Print Post  
SmartCarry, correct me if I am wrong...

Rick,
I believe they are trying to populate combo boxes as the user moves through them making selections, not based on values already stored. I suppose they could use a populated lookup database so those choices might be more easily edited when there are updates to particular lines, but I think they are more interested in making sure that combo "B" has the right choices in it, based on the user's selection on combo "A", etc.

In a change event for comboA
Code
Select All
if(comboA = "Google")
{
  PopulateListElement(comboB, "Maps;Android;Plus")
}
else if (comboA = "MS")
{
  PopulateListElement(comboB, "Word;Excel;SQLServer")
}
else if (comboA = "Apple")
{
  PopulateListElement(comboB, "IPod;iPhone;IPad")
}
 

  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Rick_R
Full Member
***
Offline



Posts: 243
Joined: Jan 29th, 2010
Re: Question about populating combo boxes
Reply #4 - Mar 8th, 2012 at 11:22pm
Print Post Print Post  
I think which approach to use would depend on how many items there are in each category and how often the items change. Either way, your PopulateListElement code would be used whether it is a static list or whether the list was obtained by xlookupall.

Also, depending on the product, a static list may be the best approach for one box (e.g., Size) and xlookup might be best for another, e.g., Model [style number] if the product is clothing.
  
Back to top
 
IP Logged
 
SmartCarry
Member
*
Offline



Posts: 3
Joined: Mar 6th, 2012
Re: Question about populating combo boxes
Reply #5 - Mar 23rd, 2012 at 5:41pm
Print Post Print Post  
Thanks for the responses.

Rick_R wrote on Mar 8th, 2012 at 9:18pm:
Check XLookupAll().  It returns all matches as a semi-colon delimited string, i.e., essentially:

Manufacturer = "ABC-Company"
AllModels = xlookupall(Manufacturer, "Products" [etc])

AllModels will come back as "ABC123;ABC345;ABC456"

Then the combo box options can be populated using that string.


This is the approach I tried. However, tabbing to the next combo box apparently doesn't trigger any event (or at least none that I can determine), so the combo box never gets populated. I'm so used to navigating through data choices in this manner using arrows to select a choice, then tabbing to the next combo box, selecting another choice, tabbing, etc..

Rick_R wrote on Mar 8th, 2012 at 11:22pm:
I think which approach to use would depend on how many items there are in each category and how often the items change. Either way, your PopulateListElement code would be used whether it is a static list or whether the list was obtained by xlookupall.

Also, depending on the product, a static list may be the best approach for one box (e.g., Size) and xlookup might be best for another, e.g., Model [style number] if the product is clothing.


This is correct. Size is a small static list of predefined values, but Model + Manufacturer + Length is a possible range of many thousands. I just wish I could get the combos to populate after tabbing.
  
Back to top
 
IP Logged
 
SmartCarry
Member
*
Offline



Posts: 3
Joined: Mar 6th, 2012
Re: Question about populating combo boxes
Reply #6 - Mar 23rd, 2012 at 5:53pm
Print Post Print Post  
Thanks for the response.

The Cow wrote on Mar 8th, 2012 at 10:03pm:
SmartCarry, correct me if I am wrong...

Rick,
I believe they are trying to populate combo boxes as the user moves through them making selections, not based on values already stored. I suppose they could use a populated lookup database so those choices might be more easily edited when there are updates to particular lines, but I think they are more interested in making sure that combo "B" has the right choices in it, based on the user's selection on combo "A", etc.

In a change event for comboA
Code
Select All
if(comboA = "Google")
{
  PopulateListElement(comboB, "Maps;Android;Plus")
}
else if (comboA = "MS")
{
  PopulateListElement(comboB, "Word;Excel;SQLServer")
}
else if (comboA = "Apple")
{
  PopulateListElement(comboB, "IPod;iPhone;IPad")
}
 



You're exactly right; I'd like to make combo box A's result determine that only valid results are displayed in combo box B.  I'd use the method you have shown as an example if it were feasible, but we sell concealed carry holsters that are sized to properly fit any handgun out here. I'm not sure exactly how many there are, but it's probably a list of many thousands. Hard-coding those choices by hand would be a significant chore. That's why I'd like to have the application execute normally in Retrieve mode, with Update/Add buttons so that the database grows as needed.
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Question about populating combo boxes
Reply #7 - Mar 23rd, 2012 at 6:07pm
Print Post Print Post  
While my example did hardcode the items, you don't have to. The point of the example was to demonstrate the logic so that the items in one menu are determined by the selection of a previous menu.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Rick_R
Full Member
***
Offline



Posts: 243
Joined: Jan 29th, 2010
Re: Question about populating combo boxes
Reply #8 - Mar 23rd, 2012 at 6:10pm
Print Post Print Post  
SmartCarry wrote on Mar 23rd, 2012 at 5:41pm:
This is correct. Size is a small static list of predefined values, but Model + Manufacturer + Length is a possible range of many thousands. I just wish I could get the combos to populate after tabbing.



You'll have to write On Exit or On Change for each combo box field that will automatically populate the next field or On Entry code for the target field.  (Realistically, I don't see On Entry code as viable, since users would be confused about the blank field that suddenly gets populated after they tab.)

There is one other issue--are there certain combinations that are much more common? Users hate having to scroll through a long list of "once in a blue moon" items for something they use constantly.  For example, on "Your Country" lists, why do web designers in the U.S. put the list completely alphabetically when 95%+ of the people will be from the U.S. and they probably won't get one 'Albania' per year?
  
Back to top
 
IP Logged
 
Rick_R
Full Member
***
Offline



Posts: 243
Joined: Jan 29th, 2010
Re: Question about populating combo boxes
Reply #9 - Mar 23rd, 2012 at 6:13pm
Print Post Print Post  
Rick_R wrote on Mar 23rd, 2012 at 6:10pm:
There is one other issue--are there certain combinations that are much more common?


By the way, aside from programming matters, knowing that information can be helpful to your marketing and purchasing departments if they don't already have it.  It can also show trends.
  
Back to top
 
IP Logged