Great - thank you. I'm still getting Script Error 800A01A8 - Object required: 'Application.Map.Layers(...)' [Line: 11, Column 1] Source Text Unavailable. I'm receiving the error both in ArcPad on my desktop and in ArcPad on my GPS unit. Here is my code:Option Explicit
'The purpose of this script is to enable the appropriate ID/NUMBER fields [ASMIS_ID, FEATURE_NUMBER, TRACKING_NUMBER]
'when a given subtype [Site, Feature, IO, Other] is selected, and to hide those ID/NUMBER fields that do not apply with the value "N/A".
'Create a subroutine to be able to pass any feature layer name to the script
Sub PopulateForm()
'Create and define Form, Page, and Control
Dim objForm, objPage, objControl
Set objForm = Application.Map.Layers(Application.UserProperties("LayerName")).Forms("EDITFORM")
Set objPage = objForm.Pages("DataEntry")
Set objControl = objPage.Controls
'If lblSUBTYPE field value is Site, do the following:
If objControl.Item("lblSUBTYPE").value = "Site" Then
'Enable txtASMIS_ID field
objControl.Item("txtASMIS_ID").Enabled = True
'Disable txtFEATURE_NUMBER field
objControl.Item("txtFEATURE_NUMBER").Enabled = False
'and set value of txtFEATURE_NUMBER field to "N/A"
objControl.Item("txtFEATURE_NUMBER").Value = "N/A"
'Disable txtTRACKING_NUMBER field
objControl.Item("txtTRACKING_NUMBER").Enabled = False
'and set value of txtTRACKING_NUMBER field to "N/A"
objControl.Item("txtTRACKING_NUMBER").Value = "N/A"
'If lblSUBTYPE field value is Feature, do the following:
ElseIf objControl.Item("lblSUBTYPE").value = "Feature" Then
'Enable txtASMIS_ID field
objControl.Item("txtASMIS_ID").Enabled = True
'Enable txtFEATURE_NUMBER field
objControl.Item("txtFEATURE_NUMBER").Enabled = True
'Disable txtTRACKING_NUMBER field
objControl.Item("txtTRACKING_NUMBER").Enabled = False
'and set value of txtTRACKING_NUMBER field to "N/A"
objControl.Item("txtTRACKING_NUMBER").Value = "N/A"
'If lblSUBTYPE field value is IO, do the following:
ElseIf objControl.Item("lblSUBTYPE").value = "IO" Then
'Disable txtASMIS_ID field
objControl.Item("txtASMIS_ID").Enabled = False
'and set value of txtASMIS_ID field to "N/A"
objControl.Item("txtASMIS_ID").Value = "N/A"
'Disable txtFEATURE_NUMBER field
objControl.Item("txtFEATURE_NUMBER").Enabled = False
'and set value of txtFEATURE_NUMBER field to "N/A"
objControl.Item("txtFEATURE_NUMBER").Value = "N/A"
'Enable txtTRACKING_NUMBER field
objControl.Item("txtTRACKING_NUMBER").Enabled = True
'If lblSUBTYPE field value is Other, do the following:
ElseIf objControl.Item("lblSUBTYPE").value = "Other" Then
'Disable txtASMIS_ID field
objControl.Item("txtASMIS_ID").Enabled = False
'and set value of txtASMIS_ID field to "N/A"
objControl.Item("txtASMIS_ID").Value = "N/A"
'Disable txtFEATURE_NUMBER field
objControl.Item("txtFEATURE_NUMBER").Enabled = False
'and set value of txtFEATURE_NUMBER field to "N/A"
objControl.Item("txtFEATURE_NUMBER").Value = "N/A"
'Disable txtTRACKING_NUMBER field
objControl.Item("txtTRACKING_NUMBER").Enabled = False
'and set value of txtTRACKING_NUMBER field to "N/A"
objControl.Item("txtTRACKING_NUMBER").Value = "N/A"
End If
'Free objects
Set objControl = Nothing
Set objPage = Nothing
Set objForm = Nothing
End Sub
Thanks,Kerry