Multiple Combo Boxes writing to one field

2588
6
07-22-2010 08:33 PM
SteveH
by
Occasional Contributor
Hi
I am building a form in AP 8 where I have multiple combo boxes hosting .dbf drop-down lists, all set to write to the same attribue field. The visibility of each combo box is determined by a series of radio buttons so that only one combo box at any time will be able to return a value.
However I can't get the attribute table to populate. Do I have to de-activate the invisible combo boxes or set the visible one to active or something?

Anyone know any scripts to do this?

thanks
Steve
Tags (3)
0 Kudos
6 Replies
KlasKarlsson
New Contributor
Hi Stephen

I created something a while ago in 7.0.1 that worked...

I called a sub-routine on the APPLICATION onstartup EVENT. In this sub I populated all my comboboxes (or in my case listboxes) from a single dbf file with the command:

Dim myVariable
Set myVariable = Forms("FormName").Pages("PAGE1").Controls("ComboName")
myVariable.AddItemsFromTable "C:\configfile.dbf", "VALUE" , "TEXT"

Hope You can use this...
0 Kudos
SteveH
by
Occasional Contributor
Hi Klas
my problem is not getting the list boxes to populate but getting the shapefile attribute table to populate.
Because there are several combo boxes, all linking to one attribute field but only one combo box ever has a value at any given time, I suspect maybe the blank combo boxes are returning the final value to the attriute table.
I have set all the non-visible combo boxes to Enabled=fasle but I still cant return a value from the enabled combo box.

Hope that makes sense...
0 Kudos
EricHajek1
Occasional Contributor
Hi Stephen,
I created a similar form sometime back, where the subtype of a feature class was selected on one page, which changed the available options for the comboboxes on other pages and had multiple comboboxes tied to one attribute. The only work around I ever found for the same problem (not saving anything) was to populate the combo boxes' options with an SQL query (it was an AXF) and not have any of the comboboxes tied to the attribute itself.

You have to then add code to save the attribute manually during the form "unload" event. Something like:
Determine which combobox you want to save based on blankness
Get a reference to the fields
field.value = combobox.value


Nothing too fancy, but still a hassle when it seems like this (if the user has multiple comboboxes tied to the same attribute, use the value of the populated one) should be part of ArcPad's logic.

Hope this helps,
Eric
0 Kudos
SteveH
by
Occasional Contributor
Thanks Eric
In the end I made a work around by removing the radio buttons and instead have interdependant combo boxes where the second combo box populates with a list dependant on the selection made in the first combo box.
Works out almost as well in this case

cheers

Steve
0 Kudos
markfarina
New Contributor
Hi

So what you have is a combobox with say...trees,shrubs,grasses and when select 'trees, the second combobox only loads up with tree species??

Mark
0 Kudos
SteveH
by
Occasional Contributor
Hi

So what you have is a combobox with say...trees,shrubs,grasses and when select 'trees, the second combobox only loads up with tree species??

Mark


Precisely.
And before you ask the code is below. In this case item chosen from a dbf list linked to "cmbActn" will populate the combobox "cmbWrkMthd"



sub SelectList 'sub to select specific entires from a dbf file for inclusion in dropdown menu on form, based on previous choice

dim pLayer, pAction, pWorkMethod, filepath, GetPath

set pLayer = Application.map.selectionLayer.Forms("EDITFORM")
pAction = pLayer.Pages("PAGE3").Controls("cmbActn").value
 
set pWorkMethod=pLayer.Pages("PAGE3").Controls("cmbWrkMthd")
if pWorkMethod.ListCount > 0 then
  pWorkMethod.Clear
end if
GetPath = Left(application.map.selectionlayer.FilePath, InStrRev(application.map.selectionlayer.FilePath, "\"))

if pAction <> "" then
  filePath = GetPath & "WorkMethod.dbf"
  pWorkMethod.AddItemsFromTable filePath, "Method", "Method", "[ACTION] = """& pAction & """"

end if

end sub 'SelectList




and the dbf for the second combobox (in this case WorkMethod.dbf) must look like this:
ACTION         METHODTXT                                     
Weed Control Spray - Chemical           
Weed Control Spray - Rust          
Weed Control Hand Removal           
Weed Control Other (Please Type)  
Fencing         Standard Fence           
Fencing         Other (Please Type)   
Revegetation Reveg with Indigenous Vegetation
Revegetation Other Reveg (Plse Type)

hope that helps

cheers
Steve H
0 Kudos