Sign in to follow this  
Followers 0
LovinItAll

Help trapping "Error"

2 posts in this topic

I have a situation where I call a form that, when fully populated, has ten checkboxes. I use the following to check them:

$oCust1 = _IEFormElementGetObjByName ($oForm, "selcust", 0)
    $oCust1.checked = True
    $oCust2 = _IEFormElementGetObjByName ($oForm, "selcust", 1)
    $oCust2.checked = True
    $oCust2 = _IEFormElementGetObjByName ($oForm, "selcust", 2)
    $oCust3.checked = True
    (etc, through ten)

There are times when there will be less than ten, however. I have used _IEFormElementGetCount($oForm) to play off of the number of elements in the form, but the resulting code is cumbersome, as each reduction in the number of checkboxes does not result in one fewer element in the form, but many. For example, fully populated with 10 checkboxes, the form has 78 elements. With three checkboxes, it only has 18. I don't think the answer lies in examining the number of elements, but rather trapping the error that occurs when there are less than ten. Of course, if there are only three checkboxes and the above code hits, I error out with "Object Not Found" (Note to Dale: This is unrelated to our previous discussion).

I have tried something like this:

$Count=1
If @error Then 
   $Count = 2
   Exit
   While $Count = 1
    $oCust1 = _IEFormElementGetObjByName ($oForm, "selcust", 0)
    $oCust1.checked = True
    $oCust2 = _IEFormElementGetObjByName ($oForm, "selcust", 1)
    $oCust2.checked = True
    $oCust2 = _IEFormElementGetObjByName ($oForm, "selcust", 2)
    $oCust3.checked = True
    $oCust4 = _IEFormElementGetObjByName ($oForm, "selcust", 3)
    $oCust4.checked = True
    $oCust5 = _IEFormElementGetObjByName ($oForm, "selcust", 4)
    $oCust5.checked = True
    $oCust6 = _IEFormElementGetObjByName ($oForm, "selcust", 5)
    $oCust6.checked = True
    $oCust7 = _IEFormElementGetObjByName ($oForm, "selcust", 6)
    $oCust7.checked = True
    $oCust8 = _IEFormElementGetObjByName ($oForm, "selcust", 7)
    $oCust8.checked = True
    $oCust9 = _IEFormElementGetObjByName ($oForm, "selcust", 8)
    $oCust9.checked = True
    $oCust10 = _IEFormElementGetObjByName ($oForm, "selcust", 9)
    $oCust10.checked = True
    $count=2
  WEnd
EndIf

I know that ObjEvent (not shown) has to be invoked somewhere, but after reading the docs, I'm not sure how to handle it. The goal, of course, is to check the remaining boxes (if less than ten) and continue the script.

Any ideas?

Share this post


Link to post
Share on other sites



No great minds to lead me in the right direction?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0