Normal Topic Combo box that adds to itself? (Read 764 times)
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Combo box that adds to itself?
Sep 11th, 2006 at 6:11pm
Print Post Print Post  
I have a field in my workorder form that allows my Dispatcher to list the names of the workers assigned to a job.  He would like to be able to select multiple names off a list, sorted by seniority, to fill this field.  He would also like to be able to type entries in without using the list.

I started with the code from the "Pizza Toppings" element in the practice program we created in the beginner programming class.  I edited it to this:
Code
Select All
var vWorkers as String
var vList as String

	// List the Workers
	vList = @Insert("Workers.txt")

	// Initialize vWorkers to a value that allows
	// the While loop to run
	vWorkers = "start"

	// As long as the user keeps selecting workers,
	// keep offering the list.
	While((vWorkers <> "*DONE")
	And (vWorkers <> ""))
	{
		vWorkers = @PopupMenu(vList, "SELECT A WORKER")
		If ((vWorkers <> "*DONE")
		And (vWorkers <> ""))
		{
			Workers_Assigned_To_Job = @AppendStringArray(Workers_Assigned_To_Job, vWorkers)
		}
	} 


This works well except that the names are sorted alphabetically, even though "Workers.txt" lists them by seniority.  Also, manual entry of text is not possible; you have to pick from the popup only.

So then I tried it as a combo box.  This fixes the sort problem but I can only choose one name, and any new choice replaces the previous one.   I tried += but then names started duplicating themselves.

So somehow I think I need to use @AppendStringArray in the combo box to continue to add names to Workers_Assigned_To_Job, but here my Sbasic programming skills fail me.  I tried putting a PopulateListElement command into the mix, and although the program editor accepted it happily, upon preview I got locked into a neverending loop which required Task Manager to break out of, and of course the .dsr was then corrupted.

Any help would be appreciated.
  

**
Captain Infinity
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Combo box that adds to itself?
Reply #1 - Sep 11th, 2006 at 6:32pm
Print Post Print Post  
1. Don't use a combo box. A combo box's job is to hold one value. Use a text box. You should probably bind it to a Keyword field.

2. Getting stuck in a While loop happens, but your dsr should not have been corrupted, only locked.

3. To allow manual entry, adjust your code or process to allow manual entry. For example, rather than use the On Element Entry event of the text box, put the code on a button next to it that the user can click if he wants the list. Otherwise, he can just type whatever he wants.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Combo box that adds to itself?
Reply #2 - Sep 11th, 2006 at 6:40pm
Print Post Print Post  
Quote:
Use a text box.

Done
Quote:
...should not have been corrupted, only locked.

No doubt this is what happened, but I freaked.  Deleted the crazy thing and went to my backup.
Quote:
...a button next to it...

D'oh.  Of course.  Thanks, I now have a working solution.  I have a text box which holds the multiple name values (not yet bound to keyword, but I will).  Next to it I have a combo box, Workers_Names, that does this:
On Element Entry
Code
Select All
// Populates the Worker Names combo box with the contents of Workers.txt

Var vWorkers as String

vWorkers = @Insert("Workers.txt")
PopulateListElement(Worker_Names, vWorkers) 



On Element Exit:
Code
Select All
// Appends the selected worker to the list of workers assigned to the job

Workers_Assigned_To_Job = @AppendStringArray(Workers_Assigned_To_Job, Worker_Names)

// Clears the Workers Names field upon exit

Clear(Worker_Names) 


It's inelegant, but it works.  Thanks for your help Erika.
  

**
Captain Infinity
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Combo box that adds to itself?
Reply #3 - Sep 11th, 2006 at 6:47pm
Print Post Print Post  
Infinity wrote on Sep 11th, 2006 at 6:40pm:
It's inelegant, but it works.  Thanks for your help Erika.


You're welcome. If you decide you also want to be elegant, let us know. Elegant AND working is an option...
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged