Select to view content in your preferred language

Multiple selections (listbox)

1552
6
05-11-2010 12:41 PM
SWCASWCA
Deactivated User
Is it possible to do a listbox in ArcPad (7.1.1) that allows for multiple selections? Or even pick one, hit "add" button, pick another, hit "add" button, etc.? Ideally these would all be concatenated (separated by comma) in a big text field in a geodatabase when checked in.

Possible?
Tags (3)
0 Kudos
6 Replies
Almarde_Ronde
Emerging Contributor
Is it possible to do a listbox in ArcPad (7.1.1) that allows for multiple selections? Or even pick one, hit "add" button, pick another, hit "add" button, etc.? Ideally these would all be concatenated (separated by comma) in a big text field in a geodatabase when checked in.

Possible?


Multiple selections in a listbox are not possible. But you can make a form of some sort with a listbox, a text field and "add" button to populate the text field. OnClick of the 'Add' button, take the current value of the selection in the listbox and collect this in a string? Something like this?

strText = strText & ", " & pListBox.Value

Routines for the listbox you can find under the "Using ListBox Controls" in Customising ArcPad help.
0 Kudos
SWCASWCA
Deactivated User
Sorry, I'm a VERY basic coder. Can you expand a little more? I understand what you are getting at, but don't know how to set it up.

Thanks.
0 Kudos
Almarde_Ronde
Emerging Contributor
Sorry, I'm a VERY basic coder. Can you expand a little more? I understand what you are getting at, but don't know how to set it up.

Thanks.


You need to make a form with a listbox, text field and button. See the ArcPad help on how to do this. Then assign an onClick event to the button that will take the value of the listbox selection and add it to the value of the text field.
I quess the code would look something like this:

'=====================================
Sub btnAdd_onClick()
'Code when clicking the "Add" button
'Will take a listbox selection value and add this to a textbox value
'=====================================
'Dimension the form, page, texfield and listbox
Dim objForm, objPage, strText, pListbox
Set objForm = Layer.Forms("EDITFORM")
Set objPage = objForm.Pages("[Page Name]")
Set pListBox = objPage.controls("[Listbox name]")
'Get existing value of textfield.
strText = objPage.Controls("[Textfield name]").Value

'Update the text field with the text value form the listbox.
'Using a comma delimiter
strText = strText & ", " & pListBox.Value
'Clean up
Set objForm = Nothing
Set objPage = Nothing
End Sub
0 Kudos
SWCASWCA
Deactivated User
Thanks for the reply and the code.

I tried it but nothing shows up in the textbox when I click the add button. I am using the onclick event of the button to call the code: "Call btnAdd_onClick()"

My listbox points to a dbf to show the choices available but the textbox is what I am using to store the values in the geodatabase.

Don't know if any of those things are effecting the process. I don't get an error message - there are just no text added to the textbox.
0 Kudos
Almarde_Ronde
Emerging Contributor
My mistake, needed to update the value of text field as well. I attached a working applet.
0 Kudos
SWCASWCA
Deactivated User
That works fantastically, thank you! I just changed it from applet back to layer for launching the form. Here is the full script in case anyone needs it. I added an if/else statement to remove the comma at the beginning:

Option Explicit

Sub ShowForm()
'===========================================
'Show the form
 Layer.Forms("EDITFORM").Show

End Sub


'=====================================
Sub btnAdd_onClick()
'Code when clicking the "Add" button
'Will take a listbox selection value and add this to a textbox value
'=====================================
'Dimension the form, page, texfield and listbox
Dim objForm, objPage, strText, pListbox
Set objForm = Layer.Forms("EDITFORM")
Set objPage = objForm.Pages("[PAGE NAME]")
Set pListBox = objPage.controls("[LISTBOX NAME]")
'Get existing value of textfield.
strText = objPage.Controls("[TEXT FIELD NAME]").Value

'Update the text field with the text value form the listbox.
'Using a comma delimiter
If strText = "" then
 strText = pListBox.Value
Else
 strText = strText & ", " & pListBox.Value
End If

objPage.Controls("[TEXT FIELD NAME]").Value = strText

'Clean up
Set objForm = Nothing
Set objPage = Nothing
End Sub


On the button on the onclick event is simply "btnAdd_onClick( )"
0 Kudos