How to toggle the properties of a control?

396
2
08-12-2010 12:08 PM
DouglasHansen
New Contributor
I am trying to create a script that will turn on specific comboboxes based on a particular value entered in another combobox on the same page.  For example, If the user chooses cbotype = "cut" I only want cbospecies, cbotrees and cbobolts to be enabled(editable) by the user.  My remaining cbodbh, cbosticks to be turned off (not enabled).  I have very little experience in vbscript so any help would be appreciated.  Thanks in advance.  This is what I have so far:

Sub MyScript
Dim objPg
Set objPg = layer.Forms("SpeciesForm").Pages("Species")
If objPg.Controls("cbotype".Value="cut" Then objPg.Controls("cbospecies").Enabled=True
objPg.Controls("cbotrees").Enabled=True
objPg.Controls("cbolts").Enabled=True
Tags (3)
0 Kudos
2 Replies
ChadFlynn
New Contributor II
Hi dhanscwc - were you able to manipulate the controls on your page like you desired? I too am searching for the right code in order to implement this functionality. My scenario is this:
Was the location inspected? [yes/no]
If not, why not? [text field: required if the above answer is no]

I've tried this code but to no avail:

Sub ReasonNotInspected

Dim locInsControl, reasonControl
Set locInsControl = Application.Forms("EDITFORM").Pages("PAGE1").Controls("domLocIns")
Set reasonControl =        Application.Forms("EDITFORM").Pages("PAGE1").Controls("txtLocInsWW")
If locInsControl.value = "No" Then
  If reasonControl.value = "" Then
   ThisEvent.MessageText = "Please enter a reason for not inspecting."
   ThisEvent.MessageType = vbExclamation
   ThisEvent.Result = False
  Else
   ThisEvent.Result = True
  End If
End If
End Sub

Thanks for any insight you may have into this.
0 Kudos
RolfBroch
Occasional Contributor II
0 Kudos