Select to view content in your preferred language

using Arcpad Studio to create form for Arcpad

4124
7
05-10-2010 08:49 AM
RebeccaBleney
Emerging Contributor
Hi All

I'm new to this and I think I've had enough of it.  I have created a combo box using a dbf as a list source, no problems.  Wanted to create a second combo box with a Select Case option that will change the shown variables depending on the first combo box.  I figured out how to do this in arcmap with vba but I can't figure out which objects' event tab to use in studio.  Or should I just use the form event tab to call up a vba but I'm not sure how to do that either.

I'm confused, help please

Rebecca
Tags (3)
0 Kudos
7 Replies
Almarde_Ronde
Emerging Contributor
Hi All

I'm new to this and I think I've had enough of it.  I have created a combo box using a dbf as a list source, no problems.  Wanted to create a second combo box with a Select Case option that will change the shown variables depending on the first combo box.  I figured out how to do this in arcmap with vba but I can't figure out which objects' event tab to use in studio.  Or should I just use the form event tab to call up a vba but I'm not sure how to do that either.

I'm confused, help please

Rebecca


When a selection is made in the first combo box, you know its ListIndex value. Perhaps you can use this value to add items to the second combobox when the "On Selection Change" event of the first box is triggered? e.g. if the 3rd value in list 1 is selected, set the source of the list 2 to the third field/column in a particular dfb?

Sub cboListOne_OnSelectionChange(ThisEventObject)
'ThisEventObject refers to the first combobox cboListOne

Dim myIndex
'Assuming a table with values listed in columns, column headers are Option1, Option2 etc
myIndex = "Option" & ThisEventObject.ListIndex
 
'Dimension the form, page and 2nd combobox control
Dim objMainPage, objEditForm, objComboControl
Set objForm = Layer.Forms("EDITFORM")
Set objPage = objEditForm.Pages("[Page Name]")
Set objComboControl = objPage.Controls("[cboListTwo]")
'Clear any existing values in cboListTwo
objComboControl.Clear
'Populate the 2nd combobox
objComboControl.AddItemsFromTable [path to table with values.dbf],myIndex,myIndex

End Sub
0 Kudos
RebeccaBleney
Emerging Contributor
Thank you for that but because I'm not a programmer of any discription, I'm still slightly confused on the coding.

When I achieved what I'm trying to do in VBA I used SELECT CASE to do it, should I be using it in Studio. I haven't had any success with it, but I might not be doing it correctly for Studio.

Or reading your suggestion gave me the idea that perhaps I could set the database that I want in the second combobox and then have the selected value of the first combobox became the field and text values for the second object box.  Do you know if that's possible?  If I understand what you were showing me, would this be the coding. 

myIndex = "Option" & ThisEventObject.ListIndex  {does this give me the selection from the first cbobox named "cbogenesis"}
Set objForm = Layer.Forms("Tree")                    {tree is the form they are both on}
Set objPage = objEditForm.Pages("[1]")              {page 1 }
Set objComboControl = objPage.Controls("[cbospecies]")          {"cbospecies" is the second cbobox}
objlistvaluefield.Clear
objlisttestfield.Clear
Set objlistvaluefield = myindex
Set objlisttestfield = myindex

Unfortunately I can't try it until I finish redoing the databases, how I did them orginally made sense to me but made the mobile Unit go at snail pace.

Rebecca
0 Kudos
RebeccaBleney
Emerging Contributor
Ok I said I didn't know what I was doing and I proved it from my last comment.  To be fair I looked at it after midnight just after I found out I had to redo the databases, which are only excel files converted to dbf.  After playing with it for many hours, I no longer get any errors but it still won't work.  Can anyone tell me what I'm doing wrong.  I put this in the cbogenesis "event on change" .  I have tried it in selonchange as well
 
Set strCboGenesis = Forms(EDITFORM).Pages(page1).controls(cboGenesis)
Set objComboControl = Forms(EDITFORM).Pages(page1).controls(cboSpecies)
Set ds = "c:\mum\please\dataforarcpad1\species.dbf"
objComboControl.Clear
objComboControl.AddItemsFromTable [ds],strCboGenesis,StrCboGenesis
0 Kudos
Almarde_Ronde
Emerging Contributor
Ok I said I didn't know what I was doing and I proved it from my last comment.  To be fair I looked at it after midnight just after I found out I had to redo the databases, which are only excel files converted to dbf.  After playing with it for many hours, I no longer get any errors but it still won't work.  Can anyone tell me what I'm doing wrong.  I put this in the cbogenesis "event on change" .  I have tried it in selonchange as well
 
Set strCboGenesis = Forms(EDITFORM).Pages(page1).controls(cboGenesis)
Set objComboControl = Forms(EDITFORM).Pages(page1).controls(cboSpecies)
Set ds = "c:\mum\please\dataforarcpad1\species.dbf"
objComboControl.Clear
objComboControl.AddItemsFromTable [ds],strCboGenesis,StrCboGenesis


The AddItemsFromTable method needs a string, i.e. AddItemsFromTable ( TableName, ValueField, TextField [,Expression] ). You are giving the ValueField and TextField in the AddItemsFromTable method a combobox object strCboGenesis instead of a string.

Suppose you have a list of values in a column in your species.dbf and that the column header in the species.dbf is called "Values". You could then say:

objComboControl.AddItemsFromTable ds,"Values","Values"

You can use the value of the cboGenesis combobox to refer to the column header in the species.dbf.

Set strCboGenesis = Forms("EDITFORM").Pages("page1").controls("cboGenesis")
myHeader = strCboGenesis.Value
objComboControl.AddItemsFromTable ds,myHeader,myHeader

Hope that makes sense?
0 Kudos
RebeccaBleney
Emerging Contributor
Thank you Thank you Thank you

I went back to the orginal suggestion, set it out one line at a time, stopped trying to SET the path and now it works.

Thank you Thank you Thank you

Just out of curiousity, can I make the index value of one field equal to another.  Say when the species have been selected I want the common name to appear automatically in another listbox.

so could I repeat the procedure and create   DS2   = path to the third database
cbospecies.vaule = cbocommon.vaule
cbospecies.listindex = cbocommon.listindex

It's not going to be that simple is it, I have to create the third database before I can try.  again I am doing this at midnight and my first ideas are not always the smartest.  Thank you again
0 Kudos
RebeccaBleney
Emerging Contributor
Its me again
I have 3 combo boxes working excatly how I want them to except if the field name has more then 10 letters.
all databases are excel converted to dbf.

first combo box reads from first database, the whole field name is seen.

the second and third combo boxes are supposed to get the field names from the first combo box but it only picks up the first 10 letters and therefore doesn't find a match.  Works perfectly when less then ten, even got the listindex thing to do what I wanted.  The fields were all made orginally as text in arcmap.

I am assuming I have to make it a string or expand the field size.  not having any luck with my attempts.  What I've got is

ds = "c:\mum\please\dataforarcpad1\species.dbf"
myHeader = objCboGenesis.Value
objCboSpecies.Clear
objCboSpecies.AddItemsFromTable ds,myHeader,myHeader


Rebecca
0 Kudos
AshleyCassol
Emerging Contributor
First of all I am not a programmer. I am working on a fire hydrant inspection form that I would like to use with ArcPad. It contains a lot of Yes/No fields. When I do the quick form it automatically adds them in as drop down boxes. Which is fine, however it would be much faster to fill out the form if they were using Checkboxes or Radio Buttons. Do I have to write code for that or can I use a "wizard" to make that happen?

Does anyone know the best way to track Yes/No fields in GIS? (Text field, ShortInteger) Do I need to use True/False (1,0) or Microsoft Access uses (Yes/No) which is Yes = -1 and No =0.

Any insight on this would be great!

Thanks,
Ashlie
0 Kudos