Select to view content in your preferred language

Writing IF/THEN/ELSE Statements in ArcPad

2204
5
06-20-2012 02:21 PM
OliviaBrown1
Emerging Contributor
I want to write an IF/THEN statement that states IF X if selected in ComboBoxA THEN txtFieldB is required, IF Y is selected from ComboBoxA THEN txtFieldC is required and ELSE txtFieldB or txtFieldC are required.  Please help!  Thank you.
Tags (3)
0 Kudos
5 Replies
GarethWalters
Deactivated User
Hi Olivia,

I have attached an applet sample for you to have a look at. I have placed the three controls and written a quick script to do the interaction.

You will see that I use the onSelChange event to execute the script.

Also I have shown two methods for you to choose from. The first is the if/else statement you asked about and the second is using the Select Case statement. You may find that the select case statement scales better if you have to add extra values to your combo box and is perhaps more logically written.

I hope this helps, if so please mark as answered, if not look forward to hearing from you.

Good luck

Gareth
0 Kudos
OliviaBrown1
Emerging Contributor
Hi Gareth,

Thanks so much for your help!

Unfortunately, I am not able to see your script.   Also, other scripts I've written have been within my AXF file.  I notice that all your work is within the apa.  Please let me know how I can view your script and if I can use the same type of scripting in an AXF.

Thanks!

Livika
0 Kudos
GarethWalters
Deactivated User
Hi Livika,

My apologies my script was empty when I uploaded it. Here is the complete file, hopefully 😄

The AXF can store the scripting exactly the same as the applet, that is one of the great things about ArcPad. If you open your AXF in Studio, open the layer definition you want to edit (you will see the form in the tree structure), then click on the script button. This will create a script file inside your AXF and you can copy and paste my script straight into the new file. You will then have to open your Edit form and and the routine to onSelChange event. Change the field names in the script if necessary and you should be good to go.

Let me know how you go.

Cheers,

Gareth
0 Kudos
OliviaBrown1
Emerging Contributor
Hi Gareth,

Thanks for your help. This is exactly what I needed!

When I was using the code you sent me, I was applying it to a layer that had already been created and had the VBScript associated with it.  I have a second layer which I have started from scratch and I would like to use the same code.  My problem is that I don't know how to add the script attribute/element to the layer like they're added to other layers.  I've attached a picture to better show what I'm attempting to explain.
0 Kudos
TimCollins1
Occasional Contributor
Hi Gareth,

It looks like this thread has been quiet for a little while, but I will ask anyway 🙂

I have a similar question to the initial question posted, except I am hoping for an 'AND' statment. I am a very new novice to programming so I may not explain this quite right.

I will try to explain with a little context. I work for a utility company and I am creating an inspection form for pole inspections. I would like to create a conditional statement that will reduce the work load of the pole inspector.

For example:

I have 3 catagories "Pole Maintenance", "Hardware Maintenance", "Conductor Maintenance". Under each catagory I have several questions about 5-7. However, if everything looks fine for a catagory I do not wish them to answer to the negative multiple times.

My idea is have one main catagory question "Does this require maintenance?" YES OR NO (1 or 0 coded values). In the event that No or 0 is selected then the X many fields are NOT REQUIRED. However, if the answer is YES or 1 then the X many fields are REQUIRED to give detail on why they selected Yes. So in 80% of the cases poles will have nothing wrong, so in this case the inspector has only to answer 3 catagory questions instead of 15-20 questions.

I hope I explained this well enough and thank you in advance for your help.

Tim
0 Kudos