I've been trying to create one list box based on a value in another and have had several problems.
First, I wanted to fill the second list when clicking on an item in the first. I couldn't figure out how to do it, there didn't seem to be a way in browser code. If someone has a way to do it, I'd love to see it.
Second, I finally opted for a button with code to fill the second list based on the first. The first list is filled by a embedded query. In the first list, I set a variable = to the value selected with this code in the "Whenever Modified" section:
i is int = ListSelect(Lst_Marketingcategories)
gpgsCampaignCategory = Lst_Marketingcategories
This didn't work, so I moved the code to a button under the "on Click" section. Then I tried to fill the second list box from code in the button like this:
//Clear Sub-Category List Box
ListDeleteAll(Lst_MarketingCategoryItems)
//Populate Sub-Category List Box
HReadSeekFirst(HFListItems,sListName,"CampaignType")
HReadSeekFirst(HFListItems,i1ActiveItem,True)
WHILE HFound()
HReadSeekFirst(HFListItems,sExtra,gpgsCampaignCategory)
If Hout() Then
Info("There are no Sub-categories for this Category")
Else
ListAdd(Lst_MarketingCategoryItems,HFListItems.sListItemCustom)
HReadNext()
END
END
This had inconsistent results, ultimately no working. Then I tried creating a query and basing the second list on that with a parameter which brings in the selected item from the first list. Haven't got this to work yet, but here's the code in the button I've got so far:
i is int = ListSelect(Lst_Marketingcategories)
gpgsCampaignCategory = Lst_Marketingcategories
Info(gpgsCampaignCategory)
HExecuteQuery(Qry_MarketingCampaignItems)
ListDisplay(Lst_MarketingCategoryItems)
ListDisplay by itself dosn't seem to refresh the list by itself, so I created a work around with a query and calling it before the ListDisplay command. While the help files say I can use the taReExecuteQuery parameter, it gives me an error when I try it.
I hope this makes sense to someone = as you can no doubt tell, I'm a newbie at this, but I thought I had it well enough to do this.
Any suggestions would be greatly appreciated.
Thanks!