Select to view content in your preferred language

Reset Script Values

501
0
08-07-2012 11:26 AM
TimCollins1
Occasional Contributor
Hi, I am relatively new to VBScript. I have done some in university however, it has been some time. I will try to explain what I am trying to perform to give some context. I have created a form that would simplifiy the inspectors life by creating a main catagory question. For example one catagory is "Pole Maintenance" The question asks "Does this pole require maintenance?" [yes/no] or [1/0]. If the answer is "no" or 0 then the script hides the following questions in the catagory and populates all the questions in that catagory with a no or 0. If "yes" 1 then the user must specify the problem by answering the remainder of the questions in the catagory. This script is called by a "onselchange" event for the initial catagory question. My script works if you select "No" then the fields are hidden and populated, however, if I change from a No to a yes then the form is not reset. Can anyone see what is wrong with the script below? Thanks!!  Tim

Sub Fields
Dim objPoleMaint
Set objPoleMaint = ThisEvent.Object
Dim PoleMaint
Set PoleMaint = objPoleMaint.Parent
Dim objBroken
Set objBroken = PoleMaint.Controls("objBroken")
Dim objScaling
Set objScaling = PoleMaint.Controls("objScaling")
Dim objCrossArms
Set objCrossArms = PoleMaint.Controls("objCrossArms")
Dim objGuyStrain
Set objGuyStrain = PoleMaint.Controls("objGuyStrain")
Dim objGuyGuard
Set objGuyGuard = PoleMaint.Controls("objGuyGuard")
Dim objGrading
Set objGrading = PoleMaint.Controls("objGrading")
Dim objBurning
Set objBurning = PoleMaint.Controls("objBurning")
Dim objPolePriority
Set objPolePriority = PoleMaint.Controls("objPolePriority")
Dim txtbox1
Set txtbox1 = PoleMaint.Controls("txtBroken")
Dim txtbox2
Set txtbox2 = PoleMaint.Controls("txtScaling")
Dim txtbox3
Set txtbox3 = PoleMaint.Controls("txtCrossArms")
Dim txtbox4
Set txtbox4 = PoleMaint.Controls("txtGuyStrain")
Dim txtbox5
Set txtbox5 = PoleMaint.Controls("txtGuyGuard")
Dim txtbox6
Set txtbox6 = PoleMaint.Controls("txtGrading")
Dim txtbox7
Set txtbox7 = PoleMaint.Controls("txtBurning")
Dim txtbox8
Set txtbox8 = PoleMaint.Controls("txtPolePriority")
Select Case objPoleMaint

' When the main catagory question is answered no, then the remaining questions are made invisible and populated with a 0 value
  Case 0
   objBroken.Visible = false
   objScaling.Visible = false
   objCrossArms.Visible = false
   objGuyStrain.Visible = false
   objGuyGuard.Visible = false
   objGrading.Visible = false
   objBurning.Visible = false
   objPolePriority.Visible = false
   objBroken.Value = 0
   objScaling.Value = 0
   objCrossArms.Value = 0
   objGuyStrain.Value = 0
   objGuyGuard.Value = 0
   objGrading.Value = 0
   objBurning.Value = 0
   objPolePriority.Value = 0
   txtbox1.Visible = false
   txtbox2.Visible = false
   txtbox3.Visible = false
   txtbox4.Visible = false
   txtbox5.Visible = false
   txtbox6.Visible = false
   txtbox7.Visible = false
   txtbox8.Visible = false
  Case 1
   objBroken.Enabled = true
   objScaling.Enabled = true
   objCrossArms.Enabled = true
   objGuyStrain.Enabled = true
   objGuyGuard.Enabled = true
   objGrading.Enabled = true
   objBurning.Enabled = true
   objPolePriority.Enabled = true
End Select
Set objBroken = Nothing
Set objScaling = Nothing
Set objCrossArms = Nothing
Set objGuyStrain = Nothing
Set objGuyGuard = Nothing
Set objGrading = Nothing
Set objBurning = Nothing
Set objPolePriority = Nothing

End Sub
Tags (3)
0 Kudos
0 Replies