Select to view content in your preferred language

Forms saving null values as string in integer field

772
2
06-29-2012 04:50 AM
RyanMendieta
Emerging Contributor
Original tweet: be nice if this form stopped saving stuff as a string (actually it's null) in my integer field. ???#arcpad??? ???#vbscript???
found by @ArcPadTeam, replied: RT @geonrd: Can you post some more detail on the ???#ArcPad??? forum, maybe we can help.

I am new at using this product so bear with me as I am not yet accustomed to the terminology.

I have a VBScript that I am using from awhile back that is used for validation of forms. The particular form field is designed to fill in a short integer field in shapefile. The VBscript's validation is written so that (in pseudocode): "if the checkbox is checked, and the value entered is not more than 0, raise alert" Basically it is a checkbox, and next to it is a text field where the user types a number.

What happens: when the checkbox is *not* checked and the text field has nothing in it, and I continue to the end, hit OK, I get an error saying Type Mismatch. The form appears to be saving a empty string into the short integer field.

My workaround: on the Values tab, I enter 0 for default value and 0 as minimum value. Error message stops.

What I think: zero should not have be entered. null should be entered. zero implies it has been inspected and reported, when that is not the case. and, I couldn't figure out where to change the Type to Integer (couldn't get CInt to work), instead of it saving a string.

Thanks for listening.
Tags (3)
0 Kudos
2 Replies
RyanMendieta
Emerging Contributor
today I learned that shapefiles cannot store null values. :mad:
0 Kudos
GarethWalters
Deactivated User
Hi Ryan,

Below I have written a quick test for you. This checks for the two scenarios you mentioned. Null should be allowed as a value in the shapefile.

This routine is being called on the Pages onValidate event:

Sub CheckNumber
Dim objPage
Set objPage = ThisEvent.Object
Dim objChkBox
Set objChkBox = objPage.Controls("Check1")
Dim objTxtBox
Set objTxtBox = objPage.Controls("Edit1")

If (objChkBox.Value = False) And (objTxtBox.Value = "") Then
    ThisEvent.Result = False
    ThisEvent.MessageText = "Please add a value to the text box > 0"
ElseIf (objChkBox.Value = True) And (objTxtBox.Value < 0) Then
    ThisEvent.Result = False
    ThisEvent.MessageText =    "Raise the alert!"
End If


End Sub


Let me know how you go.

Cheers,

Gareth
0 Kudos