Normal Topic Populate series of Combo boxes via 'Drill-Down' (Read 3550 times)
Steve_in_Texas
Senior Member
*****
Offline


No personal text

Posts: 893
Location: San Antonio
Joined: Feb 21st, 2004
Populate series of Combo boxes via 'Drill-Down'
Aug 29th, 2004 at 2:30pm
Print Post Print Post  
Combo boxes in Sesame are great tools for the user. They are easy to place on a form, change size, position, color, font, etc. They are more user-friendly than pop-up boxes (at least in ver 1.0.4), and the choices found inside a combo box can be hard-coded, or populated via programming.

Using programming to populate the combo box has got to be one of the most powerful features I've seen Sesame perform.

In the example below, you can search an inventory database by first scrolling through a list of manufacturers (Called MFGR) , then a second box allows you to scroll through a list of products made by that particular manufacturer (called Collection' in this example), then a third box will populate and let you choose various colors of the product you just selected. There is no limit as to how 'specific' this drill-down method can be.

You just create empty combo boxes on your form, and let sesame do all the work.

Since I am fairly new to programming, the program may be a bit sloppy and not as efficient as it could be, but it works. Refer to Inside Sesame August edition (last page) for a more streamlined and easier technique using Pop up boxes instead of Combo Boxes.

Also, in ver 1.0.4 there is a small bug in combo box behavior that Lantica has fixed for a future release. In the meantime, you can move this program to command buttons if you wish.

In Global Code of your form

stat vmasterlist as string   //place holder for String of items tied to their mfgr and collection names.

------------------------------

In FormName:: On Retrieve Spec Open

PopulateListElement(mfgr,@xuserselect(@fn, "mfgr")) //this will auto-populate the first box named MFGR of all the Manufacturers in your database, stripping out dupes.

-------------------------------------------------

In MFGR:: On Element Change  //currently has a bug, but may be fixed in next Sesame release.

var vduped as string
var vstring as string
var x as int = 1
var vcollection as string
var vstripped as string
var vcollections as string


if @mode() = 2 and mfgr <> "" then          //Checks for Retrieve mode and MFGR box is not empty.
{
vcollections = @XLookUpAll(@FN, mfgr, "mfgr", "collection")
if vcollections <> "" then
{
vduped = @sortstringarray(vcollections, 0)

while @len(vduped)>0
{
if @instr(vduped, ";")>0 then vstring=split(vduped, ";") else vstring = split(vduped, @newline())
if @instr(vcollection, vstring)<1 then vcollection = vcollection + vstring + ";"
vstring = ""
}
if vcollection <> "" then
{
clear(collection, pattern, color)
populatelistelement(collection, vcollection)
populatelistelement(pattern, "")
populatelistelement(color, "")
}
}
}      //This will populate the box named 'Collection' and clear out the pattern and color boxes.

---------------------------------------------

In 'Collection:: On element Change

var vduped as string
var vstring as string
var x as int =1
var vcollection as string
var vstripped as string
var vlist as string
var vfindcounter as int = 0
var vpatterns as string
var vpattern as string
var vdump as string
var vfind as int = 1

if @mode() = 2 and collection <> "" then
{
if mfgr <> ""
{
vmasterlist= @xlookupsourcelistall(@fn, mfgr, "admin!mfgr", "collection;pattern;color")
if vmasterlist <> ""
{
vlist = @replace(vmasterlist, ";", "|")    /////Creates  kathy ireland|provencal|ebony;nexus|floris|red;      
)
vlist = @replace(vlist, @newline(), ";")
vstripped = @containsstringarray(vlist, collection, 1)  ///build string of ALL matching collections with patterns and colors
vstripped = @replace(vstripped, collection, "+")
vstripped = @replace(vstripped, "+|", "")
while @instr(vstripped, "|")>0
{
vpatterns = vpatterns +split(vstripped, "|") + ";"
vdump = split(vstripped, ";")
}
if vpatterns <> "" then vduped = @sortstringarray(vpatterns, 0)       //alphebetize the list
while @len(vduped)>0                        // strip out the dupes
{
if @instr(vduped, ";")>0 then vstring=split(vduped, ";") else vstring = split(vduped, @newline())
vfind=@findstringarray(vpattern, vstring)
if vfind <1 then vpattern = vpattern + vstring + ";"
vstring = ""
}

if vpattern <> "" then
{
clear(pattern, color)
populatelistelement(pattern, vpattern)      //put the list into the Pattern combo box and clear out Color box
populatelistelement(color, "")
}
}
} //end if xlookupsourcelist failed
} //end if not in search mode
------------------------

In 'Pattern:: On element Change


var vduped as string
var vstring as string
var x as int =1
var vcollection as string
var vstripped as string
var vlist as string = "No Products found"
var vcolors as string
var vcolor as string
var vfind as int = 1

if @mode() = 2 and pattern <> "" then
{
if mfgr <> "" and collection <> "" and pattern <> ""
{
vmasterlist= @xlookupsourcelistall(@fn, mfgr, "admin!mfgr", "collection;pattern;color")
if vmasterlist <> ""
{
vlist = @replace(vmasterlist, ";", "|")    
vlist = @replace(vlist, @newline(), ";")
vstripped = @containsstringarray(vlist, collection+"|"+pattern, 1)  ///build string of ALL matching collections with patterns and colors
vstripped = @replace(vstripped, collection, "+")
vstripped = @replace(vstripped, pattern ,"+")
vstripped = @replace(vstripped, "+|", "")  //Allows each MFGR to be 'tied' to its quality and pattern and color
if vstripped <> "" then vduped = @sortstringarray(vstripped, 0)       //alphebetize the list

while @len(vduped)>0                        // strip out the dupes
{
if @instr(vduped, ";")>0 then vstring=split(vduped, ";") else vstring = split(vduped, @newline())
vfind=@findstringarray(vcolor, vstring)
if vfind <1 then vcolor = vcolor + vstring + ";"
vstring = ""
}
if vcolor <> "" then
{
clear(color)
populatelistelement(color, vcolor)      //put the list into the Color combo box
}
}
} //end if xlookupsourcelist failed
} //end if not in search mode
  
Back to top
IP Logged