Select to view content in your preferred language

ArcPad Studio Autofill Field based upon Previous Record

5532
9
07-11-2011 11:17 AM
TimHoyman
Emerging Contributor
While I have done a lot using ArcPad Studio 8, it is mostly routed in creating combo boxes to fill in very large forms (>300 lines of code) after taking a GPS point with a Toughbook CF31 tethered to a Trimble GeoXT.  We collect biological information on lakes in a grid formation which in some instances has over a 1,000 predetermined locations that we visit.

One of the fields may indicate the "Field Crew."  Is there a way that the next point taken defaults to the text entered into the "Field Crew" field from the previous point?
Tags (3)
0 Kudos
9 Replies
EricHajek1
Regular Contributor
A relative easy way to go about this is to just use a global variable. Declare it outside any subroutines you have in your attached script file, and give it the value of whatever field you want to save during the "unload" event of your form.

global_variable = ThisEvent.Object.Pages("PAGENAME").Controls("TEXT OR COMBOBOX NAME").value  'ThisEvent.Object assumes youre in the unload event of the form

Next, reassign the value to the form whenever the page with the control on it gets "focus". (ie - when that page is displayed, for whatever reason you can only set the value of controls currently being shown to the user)

So for instance, the Onsetactive event of the page with the control on it is a good place to put it.

ThisEvent.Object.Controls("TEXT OR COMBOBOX NAME").value = global_variable 'ThisEvent.Object assumes youre in the onsetactive event of a page

If you have a bunch of values like this that you want to set, then you could create a subroutine to run during the unload event which saves them all to a global variable array, and then another subroutine to reload the values when their page is displayed. You could use a select case statement on the current page name, so that you just have a simple command that is called on each page's onsetactive event:

Call ReloadValues(ThisEvent.Object.Name) 'If called in a page event sends the page name to your subroutine, which could then indicate which values to push out to the form.

Sub ReloadValues( pagename )
  Select Case pagename
     Case "Page1"
         ThisEvent.Object.Controls("TEXT OR COMBOBOX NAME").value = global_variable(1)
    'etc etc
End Sub



Hope this helps!
Eric
TimHopper
Frequent Contributor
Off the top of my head I'm not sure how you would do this through code.  There is, however, a Repeat Attributes tool which you can use to repeat ALL of the attributes from the previously created feature.  I'm not sure if having all of the attributes come over is acceptable or not, but I thought I'd make you aware of the tool.

Creating repeated features
http://help.arcgis.com/en/arcpad/10.0/help/index.html#//00s1000000r5000000.htm

In ArcPad 10, while in Design Mode, you can add the Repeat Attributes button to any toolbar, making it easy to quickly access.

Working in Design Mode
http://help.arcgis.com/en/arcpad/10.0/help/index.html#/Working_in_Design_Mode/00s10000012z000000/

Another choice you would have is to set a default value for that field either in ArcMap before you check it out, or via Studio after the AXF has been created.  Then the default value will automatically populate the field crew info for each new point. 

Additionally, you could think about utilizing templates in ArcPad 10.  Each field crew could have it's own template, with a default value already set.

What are Quick Project Templates?
http://help.arcgis.com/en/arcpad/10.0/help/index.html#//00s1000000w3000000.htm

Creating QuickProject Templates
http://help.arcgis.com/en/arcpad/10.0/help/index.html#//00s1000000w4000000.htm

Hope this helps.
0 Kudos
navSha
by
Deactivated User

I am having to deal with the same type of problem right now. For some reason the repeated features button does not work when added as a button to the toolbar from design mode. I have it added to the form as well but it does not save all the attributes.

0 Kudos
TimHopper
Frequent Contributor
Nice Eric!  Looks like you beat me by about 30 seconds.

I'll be interested to try that out.
0 Kudos
TimHoyman
Emerging Contributor
Thanks for the information.  Currently I have the crews open the .apl and change the default value for the fields.  I like the idea of Eric's response but it is outside of my skill level at this time.  When things slow down, I will try to implement these ideas. 

Thanks again.
0 Kudos
navSha
by
Deactivated User

I know im about three years to late but did you ever end up figuring something out with this?

0 Kudos
MosquitoGIS
Frequent Contributor

Here is a recent thread in which I helped someone get started on a similar issue. nav Sha‌  I don't know if this helps you or not in what you are looking for.

0 Kudos
MosquitoGIS
Frequent Contributor

I just realized the link never got posted.  Here is the link that has the code pretty much done for this guys smaller project.  Script that will hold the previous attributes of last object - ArcPad‌.  I had one mistake that dealt with the use of comboboxes, that I placed the code to do it correctly with combo boxes a couple posts down.

It has pretty step by step projects, that you may be able to get an idea on how to get it figured out pretty quick, I would hope.

0 Kudos
BrianBulla
Honored Contributor

I do this sort of this with all of our 'Inspection' applications we've developed for ArcPad.  The easiest thing I have found is to create a text file that stores the name of the last inspector.  Then when the form fires up, it just loads up the text box with the name of the Inspector, read for the text file.

I also have it setup to load up a listbox with the names of all possible inspectors from a csv text file, which adds new ones as required.

This seemed to work the best for us.

0 Kudos