James, I thought it might be useful to take Kurt’s explanation a little further and break down exactly what is being executed in the code we submitted. The
popupatmouse statement contains a formula consisting of a couple of nested functions that execute in order from the inner most outward. Let’s look at what is being handled in the order of execution. Note - you should replace YourField with the actual name of your choice field in the below code.
First is the
listchoices( function which I used in its simplest form (no options used). This will generate a carriage return list of every item that is in that field:
Next to execute is the
arraysort( function that uses the results of the above
listchoices( function. This will sort the list alphabetically:
This gives us the list of choices we need for the
popupatmouse statement. The
popupatmoouse statement requires three prameters: popupatmouse LIST, INITIAL, CHOICE. The LIST parameter is what we have just created above with the nested formula. The INITIAL parameter will be what is currently in the YourField cell and the CHOICE parameter is what will replace the current contents of that same cell when a selection is made from the popup list. This explains the use of the double ,YourField,YourField.
If you wanted to use a list of choices you already have in a return separated variable possibly created in your .Initialize procedure, you would simply replace the above formula with the variable name (let’s call it myChoiceList).
Also, if you wanted to limit your choices using the original
listchoices( function to only items that have already appeared in your field two or more times you would add the additional options:
The code you decide to use would be placed in the Code pane of the Properties panel for the field you are using. Any existing choices you have in the Choices pane for that field must be removed.