Expand my Community achievements bar.

Select item in list box using code

Avatar

Former Community Member
We use Adobe Workflow v5. I am creating a Check Request application where users type information into various fields and when they click Add, the data is added to a List Box. Also when they click Add, if the current item is >$1,000, a query searches our accounting database to see if the client has outstanding AR older than 90 days. If they do, another list box is displayed with the client name and amount of outstanding AR.

If that clientnum is already in the second list box, it does not add another one.



To delete a record from the first list box, the users select the item in the first list box, and then click a Delete button. That deletes the

record in the first list box.



I am also trying to delete the record from the second list box but am not sure how to select it using code. As part of the Delete button code, if the currently selected item (the one they want to delete) is >$1,000, I go through each row of the first list box to see if clnum.text (field in the form where the record to be deleted is now displayed) matches the client number in column 4 of any row of the first list box. If it does, I see if the amount of the item in the first list box is >$1000.

If it is, then I know that there is a corresponding record in the second list box.



Here is some of the code:



'go through each row in first list box

For irow = 1 to lstExp.ListCount



'set clientnum variable equal to client # in row in first list box

clientnum = lstExp.RetrieveItem(irow,4)



'if clientnum variable is equal to client # to be deleted from first list box (selected record - client # in clnum.text now)

if clientnum = trim(clnum.text) then



'if amt is >$1,000 in first list box

if lstExp.RetrieveItem(irow,10) > 1000 then



'don't delete row because there is another record in first list box

DeleteOutAR = "N"

else



'delete row because there is NOT another record in first list box.

DeleteOutAR = "Y"

end if

end if

Next



Here is the code I need help with. I am unsure how to select the record in the second list box so I can delete it.



if DeleteOutAR = "Y" then

'go to second list box ?

form.GoToField(lstOutARUnbilled)

'start going through second list box looking for clientnum

For irow2 = 1 to lstOutARUnbilled.ListCount

if clientnum = lstOutARUnbilled.RetrieveItem(irow2,1) then

irow2 = lstOutARUnbilled.CurrentSelection

lstOutARUnbilled.Removeitem (irow2)

end if

next

end if



So my question is, how can I move to the second list box to actually delete the record?



Thank you in advance for any help.



Mary
1 Reply

Avatar

Former Community Member
Mary-



The solution could either be quite easy or difficult dependent upon how the data is arranged in the subsequent list box.



Basically, if there is any sort of corresponding or matching entries, meaning line 1 from list box #1 matches with line 1 of listbox #2, then you would simply execute the following...



"listbox#2.RemoveItem listbox#1.CurrentSelection"



Or if you have a column that would contain the same values, say an index, then you could just loop thru the 2nd listbox searching for that index and once found remove the line...



"listbox#2.RemoveItem nRow"



, where nRow would be the line that you discovered to have the matching index.